This repository has been archived by the owner on Jul 22, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In getExcelTS, two days are added to the submitted date, for two separate reasons:
The days are then subtracted back out here:
However, a bug arises (as described in #324) when the two days are added over a daylight savings change. For example, when the UTC timestamp '2020-03-06T15:38:00Z' is passed to getExcelTS, it is received as Fri Mar 06 2020 07:38:00 GMT-0800 (Pacific Standard Time). The first addition day becomes Sat Mar 07 2020 07:38:00 GMT-0800 (Pacific Standard Time), then the second additional day crosses a daylight savings change and becomes Sun Mar 08 2020 07:38:00 GMT-0700 (Pacific Daylight Time). This is a change of 23 hours rather than 24. Although only 47 hours have been added, 2 full days are still subtracted, resulting in the output time being 1 hour early/behind. When daylight savings 'falls back' in the fall 49 hours are added and the times are 1 hour ahead.
Note that this occurs event if getExcelTS is passed a UTC date because javascript date object methods work in the local time zone of the host system.
Adding 24 hours instead of 1 day solves this bug without breaking any of the existing tests.
Thanks to @n-a-t-e for the gist identifying the bug and @mactyr for writing the solution! #324
Resources:
ECMA-376, Second Edition, Part 1 - Fundamentals And Markup Language Reference Section 18.17.4 Dates and Times
https://www.myonlinetraininghub.com/excel-date-and-time
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date