From: akr@... Date: 2016-06-13T12:39:41+00:00 Subject: [ruby-core:75992] [Ruby trunk Misc#10473] Date.to_datetime.to_time != Date.to_time Issue #10473 has been updated by Akira Tanaka. Akira Tanaka wrote: > The proposed patch seems fine. > > However I recommend to add more tests for old dates around transition between Jurian to Geregorian Calendar. I found that there are days that exists on Jurian carendar but not on Gregorian calendar. 1000/2/29 is exist on Jurian calender but it is not exist on Gregorian calendar. So, Date.new(1000, 2, 29) preveserves the arguments but Time.new(1000, 2, 29) doesn't. ``` % ruby -rdate -e ' p Date.new(1000, 2, 29) p Time.new(1000, 2, 29) ' # 1000-03-01 00:00:00 +0918 ``` So, Date.new(1000, 2, 29).to_time.to_datetime doesn't preserve the arguments (and Date.new(1000, 2, 29).to_time.to_datetime.to_date doesn't round trip). ``` % ruby -rdate -e ' d = Date.new(1000, 2, 29) p d p d.to_time p d.to_time.to_datetime p d.to_time.to_datetime.to_date ' # 1000-03-01 00:00:00 +0918 # # ``` ---------------------------------------- Misc #10473: Date.to_datetime.to_time != Date.to_time https://bugs.ruby-lang.org/issues/10473#change-59192 * Author: Jack Lowe * Status: Open * Priority: Normal * Assignee: ---------------------------------------- Date.new(2014,1,1).to_datetime.to_time.utc.to_s => "2014-01-01 00:00:00 UTC" Date.new(2014,1,1).to_time.utc.to_s => "2014-01-01 05:00:00 UTC" -- https://bugs.ruby-lang.org/ Unsubscribe: