Giter VIP home page Giter VIP logo

Comments (4)

spencermountain avatar spencermountain commented on August 11, 2024

hey, thanks for your help.
Yeah, in my opinion, .add(1, 'week') should compensate for the dst change, and move a full 7 days. That seems to be working right now.

it looks like the confusion is in the .diff() results then.
We may want to add this 'dst compensate' stuff to .diff.

hmmm. Do you agree?

(ps you don't need to use .clone() anymore for that)

from spacetime.

hunteva avatar hunteva commented on August 11, 2024

Hi, @spencermountain, thanks for merge my changes, I'm really happy to help here.

Just want to be clear that current implementation is what your described, it works like this

> spacetime('2018-03-29T00:00:00.000+13:00').add(1, 'week').format('iso')
2018-04-04T23:00:00.000+12:00

Not exactly 'full 7 days' literally but 7 days worth of ms.

I'm totally agree the idea of dst awareness diff, just haven't figure out what's the more proper way to interprete the results, eg:

start = '2018-03-29T00:00:00.000+13:00'

  • Options 1, loyally repensents the ms
    diff('2018-04-04T23:00:00.000+12:00', start) output 7 days
    diff('2018-04-05T00:00:00.000+12:00', start) output 7 days 1 hour

  • Options 2, compensate to dst, but might be weird looking
    diff('2018-04-04T23:00:00.000+12:00', start) outputs 6 days 24 hours (because dst crossing on 01/Apr makes that day 25 hours long. it might end up been xxxxx days xxx hours for long distant dates crossing dst multiple times)
    diff('2018-04-05T00:00:00.000+12:00', start) outputs 7 days

any suggestions?

from spacetime.

spencermountain avatar spencermountain commented on August 11, 2024

oh hey, you're completely right. Thank you. I was wrong yesterday.
yeah, adding a week to thursday at 4pm should always return a result at thursday at 4pm.

the add function is not correct then. The diff calculation can just use the same methods, so will not require any additional dst awareness step.

Sorry about this. I can take a look at this, this week - or I will happily merge a PR with however you decide to fix it.
thanks!

from spacetime.

hunteva avatar hunteva commented on August 11, 2024

hi, @spencermountain the PR has been filed, now add function does exactly what we discussed for 'year/season/quarter/month/week/days', but not for 'hour/minutes/sec' since that's some exact number user ask to add.

Please let me know your thoughts, Thanks!

from spacetime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.