Comments (4)
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.
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.
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.
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)
- Unexpected results near DST 2023 boundaries (Europe/Helsinki) HOT 4
- Month number is always -1 HOT 3
- ISO offset vs IANA code ambiguities HOT 5
- DST Result for "Asia/Tehran" is wrong HOT 1
- [Typescript] Could not find declaration file for module 'spacetime' HOT 1
- dayOfYear in leap years HOT 3
- Failing timezone conversion from Zulu to Europe/Rome HOT 1
- Times of the day seem illogical HOT 9
- week function not working correctly HOT 8
- Specific date is not getting the correct epoch HOT 1
- toNativeDate does not factor in timezone offset HOT 3
- Question about making plugins HOT 4
- The new zone `America/Ciudad_Juarez` is missing HOT 3
- Spacetime not working in MacOS Sonoma (Cannot find timezone named: 'cet'. Please enter an IANA timezone id) HOT 7
- Epoch values not updating for different timezones HOT 4
- Incorrect Africa/Casablanca offset HOT 3
- Daylight savings error with timezone HOT 1
- Africa/Cairo: wrong TZ offset HOT 3
- Subtract TZ offset
- Module '"spacetime"' has no exported member 'Spacetime'. Did you mean to use 'import Spacetime from "spacetime"' instead? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spacetime.