Comments (3)
Can you verify if the native JS Date object in the same timezone is afflicted with the same issue? A lot of these inconsistencies around the DST leap are not specific to the lib, they're just due to the fact that under the hood we're using JS Date.
from timezone-js.
It's somehow irrelevant how native object behaves because it doesn't support timezones and the bug is caused because I want to get Date object of different timezone than my local timezone.
But anyways, I switched my computer to UTC and ran the same tests, and everything is OK:
(new Date(1414281600*1000)).getHours() // 0
(new Date(1414285200*1000)).getHours() // 1
(new Date(1414288800*1000)).getHours() // 2
If using native JS Date under the hood causes bad calculations then it simply means that this approach is flawed and should be abandoned.
I just had similar problems with python "croniter" library last week. It also runs calcuations on naive (local) datetime internally causing bad calculations around DST changes of computer timezone.
I understand that this is an open source project, a lot of work was put into it and I'm in no position to demand anything but I see a lot of similar tickets in the issue tracker. I think that in order to avoid a lot of frustration there should be at least clear information on main page that this library does not produce valid calculations of any timezone around DST changes of computer's local timezone.
from timezone-js.
The problems with native Date are relevant because the common issues file with this lib about DST leap involve how datetimes inside the leap-window are handled. Whenever someone files a bug related to the leap, I ask about that first. Native JS Date doesn't handle timezones, but it does handle the DST leap, and it does it in a way that is not necessarily what everyone Engineering is all about tradeoffs. If a particular approach has problems, it may still have enough other advantages to make it worth pursuing. I understand your frustration here, and it would be great if I had time to gut this library and start over. It's been around for almost 10 years now, and is pretty crufty. It seems to provide enough value for people that it's worth continuing to maintain.
If you'd like to take a stab at some sort of "caveat emptor" wording for the README, I'd be happy to update it. Note however "Does not produce valid calculations of any timezone around DST changes of computer's local timezone" is not in my experience a valid depiction of the behavior of the library, or a correct characterization of the various issues it has. I don't think that's quite fair.
from timezone-js.
Related Issues (20)
- setTime unable to progress over DST start (NZST to NZDT) HOT 1
- Invalid region for some timezones HOT 4
- Browserify require timezone-js raise uncaught error HOT 4
- getTimezoneOffset() does not work with DST HOT 2
- date.setMonth() on a date outputs wrong month HOT 5
- Error: Timezone 'Europe/Copenhagen' is either incorrect, or not loaded in the timezone registry. HOT 1
- Timezone incorrect or not loaded in the timezone registry HOT 1
- incorrect timezone abbreviations HOT 2
- DST problem after upgrading HOT 1
- toISOString returns incorrect value near (but not during) DST change HOT 1
- Incorrect time transition moment HOT 1
- timezoneJS constructor returns wrong offset and timezone HOT 1
- tzdata now available as NPM modules HOT 3
- invalid date HOT 1
- missing timezone names HOT 1
- Error while setting up with Olson files (missing file) HOT 1
- Failure for years < 100 AD HOT 3
- Wrong date conversion for certain years in daylight saving time HOT 1
- Wrong Date conversion for the years below 1947 in Kuwait Timezone(UTC+3). HOT 1
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 timezone-js.