Skip to content

Inconsistent return value of valueOf() on differnt NodeJS versions #5207

@StefanPavlik

Description

@StefanPavlik

Bug description
The return value of Moment.valueOf() 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:

for (let i = 1800; i < 2000; i++) {
  const dateStr = i + '-01-01';
  console.log(moment(dateStr).valueOf() + '    ' + dateStr);
}

Expected behavior
I think that return value of Moment.valueOf() should be the same regardless of NodeJS version.

Results from my computer:
moment.valueOf_on_node_8.16.1.txt
moment.valueOf_on_node_10.3.0.txt
moment.valueOf_on_node_10.4.0.txt
moment.valueOf_on_node_10.16.3.txt

Environment:

  • OS: Windows 10 1809 (64bit)
  • NodeJS (versions 8.16.1; 10.3.0; 10.4.0; 10.16.3)

Moment-specific environment:

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

With NodeJS 8.16.1 the output is:

Fri Aug 23 2019 10:05:12 GMT+0200 (Central Europe Daylight Time)
2019-8-23 10:05:12
-120
2.24.0

With NodeJS 10.16.3 the output is:

Fri Aug 23 2019 10:05:26 GMT+0200 (Central European Summer Time)
8/23/2019, 10:05:26 AM
-120
2.24.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions