Time correction applied to Date constructor when creating events #80
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.
This pull request is in response to Issue #15 in js-year-calendar and issue 27 in rc-year-calendar.
The default JavaScript date constructor initialises date objects using the local time of the machine (a terrible idea) - resulting in examples such as this:
new Date(2022, 06, 12, 0, 0, 0, 0) => 12th June 2022 00:00:00 (+01:00 BST)
When this is further converted to strings later in the program, a time correction is applied to convert to UTC and the date becomes: 11th June 2022 23:00:00
This has the effect of reducing the start date and end date of new events by one whole day for all time zones with a time zone ahead of Greenwich Mean Time
The bug still exists, but is not visible to the user if you are in North or South America:
new Date(2022, 06, 12, 0, 0, 0, 0) => 12th June 2022 00:00:00 (-04:00 EDT)
This becomes 12th June 2022 04:00:00 if set to a UTC string - which is truncated to 12th June 2022 as the application discards the time portion of the Date object
If you are fortunate enough to live in the UK, the bug is visible only if the event start or end dates fall within British Summer Time, and is not visible if the dates fall within Greenwich Mean Time
This merge will apply a time correction to created Date objects when initialising an event, equal to the time zone offset which is set by the local computer