Skip to content
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

Inconsistent Date.prototype.getTime() value across different Node.js versions #29900

Closed
StefanPavlik opened this issue Oct 9, 2019 · 2 comments
Labels
i18n-api Issues and PRs related to the i18n implementation. v8 engine Issues and PRs related to the V8 dependency.

Comments

@StefanPavlik
Copy link

  • Version: 10.16.3
  • Platform: Windows 10 1809 (build 17736.805), 64 bit OS

Bug description
The return value of Date.prototype.getTime() is not consistent with different versions of NodeJS.
It seems that the problem started since NodeJS version 10.4.0

To reproduce
Run following code with different NodeJS verions:

  const MAX_DATE = new Date(2000, 0, 1);
  let date = new Date(1800, 0, 1);
  while (date < MAX_DATE) {
    console.log(date.toISOString() + '\t' + date.getTime());
    date = new Date(date.getFullYear() + 1, 0, 1);
  }

Results from my computer:
date_nodejs_v8.16.1_data.txt
date_nodejs_v10.3.0_data.txt
date_nodejs_v10.4.0_data.txt
date_nodejs_v10.16.3_data.txt

Expected behavior
I think that return value of Date.prototype.getTime() should be the same regardless of NodeJS version.

Addition information:
Output of following code:

console.log((new Date()).toString())
console.log((new Date()).toLocaleString())
console.log((new Date()).getTimezoneOffset())

with Node.js version 8.16.1:

Wed Oct 09 2019 11:22:47 GMT+0200 (Central Europe Daylight Time)
2019-10-9 11:22:47
-120

with Node.js version 10.16.3:

Wed Oct 09 2019 11:24:07 GMT+0200 (Central European Summer Time)
10/9/2019, 11:24:07 AM
-120
@StefanPavlik
Copy link
Author

StefanPavlik commented Oct 9, 2019

I have filled similar issue to moment Node.js module: moment/moment#5207, but it seems that the main problem is in Node.js (V8) or even somewhere else...

@bnoordhuis
Copy link
Member

The date is formatted by V8 and the ICU libraries and they receive occasional updates that may change the output. Importantly, the embedded timezone database is updated every few months.

I'm going to close this out because it's not under the control of Node.js but thanks anyway for the report.

@bnoordhuis bnoordhuis added i18n-api Issues and PRs related to the i18n implementation. v8 engine Issues and PRs related to the V8 dependency. labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n-api Issues and PRs related to the i18n implementation. v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

2 participants