gives inconsistent results depending on the timezone the computer is running it in. For example, a computer in the America/New_York timezone would log out 2020-01-02T15:14:59.741Z whereas a computer in UTC would log out 2020-01-02T20:14:59.741Z.
I believe this is due to the following line of code:
For the computer in America/New_York, running new Date().getTimezoneOffset() gives 300 and for the computer in UTC, it would give 0. In both computers, dayjsObj.$offset is -300 and there is no dayjsObj.$x.$localOffset. As a result, addedOffset would be 0 for the computer in America/New_York but -300 for the computer in UTC. This addedOffset would be used to create a new Date object in which the ISO string is derived from.
Is this intended behavior or should the dayjsObj provide the same ISO string regardless of the timezone a computer is running in?
Running
gives inconsistent results depending on the timezone the computer is running it in. For example, a computer in the
America/New_York
timezone would log out2020-01-02T15:14:59.741Z
whereas a computer inUTC
would log out2020-01-02T20:14:59.741Z
.I believe this is due to the following line of code:
https://github.com/iamkun/dayjs/blob/a9d7d0398d22ebd4bfc3812ca0134a97606d54d9/src/plugin/utc/index.js#L117
For the computer in
America/New_York
, runningnew Date().getTimezoneOffset()
gives300
and for the computer inUTC
, it would give0
. In both computers,dayjsObj.$offset
is-300
and there is nodayjsObj.$x.$localOffset
. As a result,addedOffset
would be0
for the computer inAmerica/New_York
but-300
for the computer inUTC
. ThisaddedOffset
would be used to create a newDate
object in which the ISO string is derived from.Is this intended behavior or should the
dayjsObj
provide the same ISO string regardless of the timezone a computer is running in?