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

Handle TZInfo::AmbiguousTime errors #31128

Merged
merged 1 commit into from Nov 15, 2017
Merged

Conversation

pixeltrix
Copy link
Contributor

@pixeltrix pixeltrix commented Nov 11, 2017

Make ActiveSupport::TimeWithZone match Ruby's handling of ambiguous
times by choosing the later period, e.g.

Ruby:

ENV["TZ"] = "Europe/Moscow"
Time.local(2014, 10, 26, 1, 0, 0)   # => 2014-10-26 01:00:00 +0300

Before:

>> "2014-10-26 01:00:00".in_time_zone("Moscow")
TZInfo::AmbiguousTime: 26/10/2014 01:00 is an ambiguous local time.

After:

>> "2014-10-26 01:00:00".in_time_zone("Moscow")
=> Sun, 26 Oct 2014 01:00:00 MSK +03:00

Fixes #17395.

Make `ActiveSupport::TimeWithZone` match Ruby's handling of ambiguous
times by choosing the later period, e.g.

Ruby:
```
ENV["TZ"] = "Europe/Moscow"
Time.local(2014, 10, 26, 1, 0, 0)   # => 2014-10-26 01:00:00 +0300
```

Before:
```
>> "2014-10-26 01:00:00".in_time_zone("Moscow")
TZInfo::AmbiguousTime: 26/10/2014 01:00 is an ambiguous local time.
```

After:
```
>> "2014-10-26 01:00:00".in_time_zone("Moscow")
=> Sun, 26 Oct 2014 01:00:00 MSK +03:00
```

Fixes #17395.
@pixeltrix pixeltrix merged commit ebc6b17 into master Nov 15, 2017
@pixeltrix pixeltrix deleted the handle-ambigious-times branch November 15, 2017 11:25
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.

None yet

2 participants