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)
'
#<Date: 1000-02-29 ((2086367j,0s,0n),+0s,2299161j)>
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
'
#<Date: 1000-02-29 ((2086367j,0s,0n),+0s,2299161j)>
1000-03-01 00:00:00 +0918
#<DateTime: 1000-03-01T00:00:00+09:18 ((2086367j,52861s,0n),+33539s,2299161j)>
#<Date: 1000-03-01 ((2086368j,0s,0n),+0s,2299161j)>
```


----------------------------------------
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: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>