Deno: std/datetime: day of year test fails in certain timezones

Created on 13 Sep 2020  路  6Comments  路  Source: denoland/deno

I'm in the east coast timezone and the dayOfYear test from std/datetime fails on the first assertion (aka it thinks January 1st 00:00 is December 31st). Changing the timezone on my machine fixes the issue.

All 6 comments

cc @timreichen

Did some digging, I _think_ it has to do with the fact that we use getFullYear instead of getUTCFullYear to compare the date with Jan 1st of the same year. I did some tests locally and that seemed to fix the problem, but I got stuck because the fix broke the tests for 400 BC

I am on it. @wperron: you are right. getUTCFullYear fixes the problem.
The 400 BC test is broken, because a zero is missing. new Date("-00400-01-01") gets parsed to year 400 instead of -400. new Date("-000400-01-01") works as expected.
PR #7466

@timreichen I noticed it that too actually, I figured if it was -00400 it was probably right 馃槄 I should've just asked

PR is merged. I think this issue can be closed.

https://github.com/denoland/deno/pull/7726 this is a slightly more robust way of resolving the timezone issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ry picture ry  路  3Comments

somombo picture somombo  路  3Comments

sh7dm picture sh7dm  路  3Comments

CruxCv picture CruxCv  路  3Comments

watilde picture watilde  路  3Comments