New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hours on day of UNIX epoch don't work correctly #47
Comments
Weird, works for me. What's your local timezone? Could you post more details e.g. run the code below var strftimeUTC = require('../strftime.js').strftimeUTC;
var date = new Date(0);
console.log(date.getTime());
console.log(date.getTimezoneOffset());
console.log(date.getHours());
console.log(date.getUTCHours());
console.log(strftimeUTC('%H', date)); |
Here's the code I ended up running: var strftime = require('strftime');
var strftimeUTC = strftime.strftimeUTC;
var date = new Date(0);
console.log('getTime:', date.getTime());
console.log('getTimezoneOffset:', date.getTimezoneOffset());
console.log('%Z %z:', strftime('%Z %z', date));
console.log('getHours:', date.getHours());
console.log('getUTCHours:', date.getUTCHours());
console.log('%H:', strftimeUTC('%H', date));
console.log();
date = new Date();
console.log('getTime:', date.getTime());
console.log('getTimezoneOffset:', date.getTimezoneOffset());
console.log('%Z %z:', strftime('%Z %z', date));
console.log('getHours:', date.getHours());
console.log('getUTCHours:', date.getUTCHours());
console.log('%H:', strftimeUTC('%H', date)); And here's the result:
I should note that while it shows a different time zone between these, using $ date -u --date='@0'
Thu Jan 1 00:00:00 UTC 1970
$ date --date='@0'
Thu Jan 1 12:00:00 NZST 1970 |
samsonjs
added a commit
that referenced
this issue
Mar 4, 2015
…ntWorkCorrectly (Fixes #47) Fix conversion of date to UTC
Thanks for the report @NelsonCrosby. This will get rolled into a release soon. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
strftimeUTC prints
01
for'%H
instead of00
whend.getTime() === 0
, however only on the day of the UNIX epoch:This doesn't seem to happen on other days:
This causes things to go a bit wrong when doing a stopwatch-like thing. A quick-fix is to add 86400000 (1 day) whenever using
Date.setTime()
, and subtract when usingDate.getTime()
.The text was updated successfully, but these errors were encountered: