Created
September 28, 2012 14:13
-
-
Save fj/3800120 to your computer and use it in GitHub Desktop.
Why time zones suck
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ψ irb --prompt=simple | |
require 'tzinfo' | |
# => true | |
tz = TZInfo::Timezone.get 'Asia/Shanghai' | |
# => #<TZInfo::DataTimezone: Asia/Shanghai> | |
tz.local_to_utc Time.mktime(1927, 12, 31, 23, 54, 5) | |
# => 1927-12-31 15:48:13 UTC | |
tz.local_to_utc Time.mktime(1927, 12, 31, 23, 54, 6) | |
# => 1927-12-31 15:48:14 UTC | |
tz.local_to_utc Time.mktime(1927, 12, 31, 23, 54, 7) | |
# => 1927-12-31 15:48:15 UTC | |
tz.local_to_utc Time.mktime(1927, 12, 31, 23, 54, 8) | |
# TZInfo::AmbiguousTime: Time: 1927-12-31 23:54:08 UTC is an ambiguous local time. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment