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

Wrong time calculation when start or end of range is in DST change day #485

Open
xplwowi opened this issue Jan 5, 2020 · 0 comments
Open
Labels
Status: needs triage Issue has not been properly analyzed yet.

Comments

@xplwowi
Copy link

xplwowi commented Jan 5, 2020

Algorithm used in changeTime() and setRange() works incorrectly when start or end date falls on DST change day.

Currently both functions set date/time to beginning of the day then add to it selected hours and minutes, this way:

opt[name] = parseInt(
    moment(parseInt(date))
    .startOf('day')
    .add(moment(opt[name + 'Time']).format('HH'), 'h')
    .add(moment(opt[name + 'Time']).format('mm'), 'm')
    .valueOf()
);

For example, for year 2020 when selected time range is 00:00 – 23:59:

  • on spring DST change day (29.03) 1 hour is added to the calculation and picker selects additionally whole 30.03
  • on autumn DST (25.10) 1 hour is subtracted and selection changes to 00:00 – 22:59

Problem can be solved by setting hours and minutes directly instead of adding them to the beginning of the day.

opt[name] = parseInt(
    moment(parseInt(date))
    .startOf('day')
    .hour(moment(opt[name + 'Time']).format('H'))
    .minute(moment(opt[name + 'Time']).format('m'))
    .valueOf()
);
@monovertex monovertex added the Status: needs triage Issue has not been properly analyzed yet. label Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: needs triage Issue has not been properly analyzed yet.
Projects
None yet
Development

No branches or pull requests

2 participants