feat: add support for timezone with seconds offset #47
+320
−9
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.
Why
Issue 46
I encountered an issue with the TZDate class when handling dates before the implementation of the GMT system in 1883. The TZDate class appears to only consider the hour and minute of the timezone, but not the seconds, leading to inconsistencies.
Example
Additional Information: The issue seems to stem from TZDate only considering the hour and minute of the timezone, but not the seconds. This discrepancy becomes apparent for dates before 1883, when the GMT system was implemented. The offset GMT-07:52:58 (America/Los_Angelos, GMT-08:00) causes the inconsistency.
Proposed Fix
The offsetStr in tzOffset already contains the timezone data for hours, minutes, and seconds. The tzOffset function returns the offset in minutes. To avoid breaking changes, I added the seconds offset as a decimal number.
In mini.js, we need to adjust the date to the system timezone. The native JavaScript Date object's .getTimezoneOffset method returns only the minutes and no seconds. To circumvent this, I create a new date and set the UTCSeconds to 0. With this, the seconds are the timezone offset of the system timezone. We then add this together with our tzOffset seconds to get the correct date.
If you don´t like any part of this PR, please tell me and I can try to find a different solution.