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

Conversation

Projects
None yet
2 participants
@pixeltrix
Member

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.

Handle `TZInfo::AmbiguousTime` errors
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

3 checks passed

codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@pixeltrix pixeltrix deleted the handle-ambigious-times branch Nov 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment