Issue #6720 has been updated by usa (Usaku NAKAMURA).

Category changed from ext to core
Status changed from Open to Assigned
Assignee set to akira (akira yamada)

IMO, this is the problem of Time, not DateTime.
I think that this may be a limitation of Time. 
Anyway, it is that akr judges. 

----------------------------------------
Feature #6720: Discrepancy between DateTime#strftime('%s') and Time#strftime('%s') before 1582-10-15
https://bugs.ruby-lang.org/issues/6720#change-27936

Author: phasis68 (Heesob Park)
Status: Assigned
Priority: Normal
Assignee: akira (akira yamada)
Category: core
Target version: 2.0.0


I found some discrepancy between DateTime#strftime('%s') and Time#strftime('%s') on date before 1582-10-15

Consider this

C:\>irb
irb(main):001:0> require 'date'
=> true
irb(main):002:0> Time.at(DateTime.new(0).strftime('%s').to_i)
=> -0001-12-30 09:00:00 +0900

irb(main):003:0> Time.at(DateTime.new(1000).strftime('%s').to_i)
=> 1000-01-06 09:00:00 +0900

irb(main):004:0> Time.at(DateTime.new(1500).strftime('%s').to_i)
=> 1500-01-10 09:00:00 +0900

irb(main):005:0> Time.at(DateTime.new(1582).strftime('%s').to_i)
=> 1582-01-11 09:00:00 +0900

irb(main):006:0> Time.at(DateTime.new(1582,10,4).strftime('%s').to_i)
=> 1582-10-14 09:00:00 +0900

irb(main):007:0> Time.at(DateTime.new(1582,10,5).strftime('%s').to_i)
ArgumentError: invalid date
        from (irb):44:in `new'
        from (irb):44
        from c:/usr/bin/irb.bat:19:in `<main>'
	
irb(main):008:0> Time.at(DateTime.new(1582,10,15).strftime('%s').to_i)
=> 1582-10-15 09:00:00 +0900

irb(main):050:0> Time.at(DateTime.new.strftime('%s').to_i)
=> -4713-11-24 09:00:00 +0900

irb(main):009:0> Time.at(DateTime.new(1583).strftime('%s').to_i)
=> 1583-01-01 09:00:00 +0900

irb(main):051:0> DateTime.new
=> #<DateTime: -4712-01-01T00:00:00+00:00 ((0j,0s,0n),+0s,2299161j)>

I understand the dates between 1582-10-05 and 1582-10-14 are invalid.
But I cannot understand why the discrepancy changes for each year.

Is the discrepancy inevitable and should not use DateTime#strftime('%s') before 1582-10-15?

I think DateTime#strftime('%s') should return same result with Time#strftime('%s') always.



-- 
http://bugs.ruby-lang.org/