Skip to content

Fix TimeZone conversion #871

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

Merged
merged 1 commit into from
Mar 22, 2016
Merged

Fix TimeZone conversion #871

merged 1 commit into from
Mar 22, 2016

Conversation

qingfx
Copy link
Contributor

@qingfx qingfx commented Mar 18, 2016

The issue is caused by different assumptions about current Date object's timezone. Such assumption should not be made within timezoneAdjust as it does not know where the Date object comes from.
For one case, if the Date object is passed in by 'getDate', the Date object has an implied timezone of current TP instance's timezone setting. However, timezoneAdjust would have incorrectly assumed that the Date object's actual timezone is held by date.getTimezoneOffset().

Another issue is that inside timezoneAdjust, the calculation for adjusting Date object is wrong. The minutes should first be adjusted to UTC timezone, by substracting offset; then the resulted minutes can be adjusted to toTimezone, by adding the offset.

The issue is caused by different assumptions about current Date object's timezone. Such assumption should not be made within timezoneAdjust as it does not know where the Date object comes from.
For one case, if the Date object is passed in by 'getDate', the Date object has an implied timezone of current TP instance's timezone setting. However, timezoneAdjust would have incorrectly assumed that the Date object's actual timezone is held by date.getTimezoneOffset().

Another issue is that inside timezoneAdjust, the calculation for adjusting Date object is wrong. The minutes should first be adjusted to UTC timezone, by substracting offset; then the resulted minutes can be adjusted to toTimezone, by adding the offset.
trentrichardson added a commit that referenced this pull request Mar 22, 2016
@trentrichardson trentrichardson merged commit 30277c2 into trentrichardson:dev Mar 22, 2016
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