Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

fix Calendar bug for new Russian timezones #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jakub-g
Copy link

@jakub-g jakub-g commented Nov 18, 2014

I'm opening this PR for reference for poor souls who still have YUI2 apps.

You might be likely interested in it if you have Windows-based customers (using Firefox) in Russia.


This commit fixes a bug manifesting itself in Calendar widget
due to recent permanent timezone changes in Russia

Then, click ">" to move to next month.
You expected to see January 2015 but December 2015 was displayed instead.

Under the hood, the problem is that the following JS:

new Date((new Date(2014,11,1).setMonth(0))).getFullYear()

evaluates to 2013 in Firefox in the mentioned locale
(the exact date is Tue Dec 31 2013 23:00:00 GMT+0300)
It evaluates to 2014 in Chrome 38 and IE9.

In the YUI2 Calendar code, the dates are initialized with "12:00:00" hour
to avoid DST-related problems, but the findMonthStart method was
returning a date with "00:00:00" time, this was propagated and hence
from certain point of calendar lifetime, all the dates had hour reset
to "00:00:00".

The fix changes the dates returned by findMonthStart to be also midday
instead of midnight which solves the Russian timezone change-related
problems and perhaps some other similar types of problems.

This commit fixes a bug manifesting itself in Calendar widget
due to recent permanent timezone changes in Russia

- affected browser: Firefox (any version, including 33-36) and Safari
  5.1.7 for Windows
- operating system: Windows 7 with the patches from August 2014 announced on
  http://blogs.technet.com/b/dst2007/archive/2014/08/22/announcement-update-for-russian-time-zone-changes.aspx
- set your timezone to "(UTC+03:00) Moscow, St. Petersburg, Volgograd (RTZ 2)"
- set your operating system date between 1 Nov 2014 and 31 Dec 2014
- open http://yui.github.io/yui2/docs/yui_2.9.0_full/examples/calendar/quickstart.html
- navigate to December 2014

Then, click ">" to move to next month.i
You expected to see January 2015 but December 2015 was displayed instead.

Under the hood, the problem is that the following JS:

  new Date((new Date(2014,11,1).setMonth(0))).getFullYear()

evaluates to `2013` in Firefox in the mentioned locale
(the exact date is Tue Dec 31 2013 23:00:00 GMT+0300)
It evaluates to `2014` in Chrome 38 and IE9.

In the YUI2 Calendar code, the dates are initialized with "12:00:00" hour
to avoid DST-related problems, but the `findMonthStart` method was
returning a date with "00:00:00" time, this was propagated and hence
from certain point of calendar lifetime, all the dates had hour reset
to "00:00:00".

The fix changes the dates returned by `findMonthStart` to be also midday
instead of midnight which solves the Russian timezone change-related
problems and perhaps some other similar types of problems.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant