Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time correction applied to Date constructor when creating events #80

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

CalumMortimer
Copy link

@CalumMortimer CalumMortimer commented Jan 12, 2022

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

@dgillier
Copy link

dgillier commented Sep 9, 2023

Any change to merge this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants