Created
October 31, 2014 17:51
-
-
Save fj/d29795586fccc744bdf5 to your computer and use it in GitHub Desktop.
perplexing round-trip Time instance behavior
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
t1 = Time.now | |
# => 2014-10-31 13:48:12 -0400 | |
t2 = Time.at(t1.to_i) | |
# => 2014-10-31 13:48:12 -0400 | |
t1.to_a | |
# => [12, 48, 13, 31, 10, 2014, 5, 304, true, "EDT"] | |
t2.to_a | |
# => [12, 48, 13, 31, 10, 2014, 5, 304, true, "EDT"] | |
t1.to_a == t2.to_a | |
# => true | |
t1 == t2 | |
# => false # !!!!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This happens because Time is tracking subsecond precision, but that's not reflected in the array or in any representation of its state: