paulbartrum / jurassic

A .NET library to parse and execute JavaScript code.
MIT License
868 stars 121 forks source link

Date.UTC() doesn't interpret two-digit years correctly #220

Closed kpreisser closed 1 year ago

kpreisser commented 1 year ago

According to the ES5.1 and ES2015 spec, Date.UTC(year, month, ...) should add 1900 to year when 0 ≤ year ≤ 99, but Jurassic (tested with commit https://github.com/paulbartrum/jurassic/commit/a22ef7ca7c47f156282f19d2c1180f8a3701ab6a) currently interprets it as full year (whereas for the new Date(...) constructor, the behavior is correct).

Expected behavior:

console.log(Date.UTC(70, 0)); // Should print "0"

Actual behavior:

console.log(Date.UTC(70, 0)); // Prints "-59958144000000"

Thanks!

paulbartrum commented 1 year ago

Thanks for the bug report, I've done a fix :-)