Bug #6683
closedDateTime#strftime("%s") overflow on 32-bit platform
Description
The improvements to date and time in 1.9.3 introduced a regression from 1.9.2 with respect to DateTime#strftime("%s") (%s is seconds since the UNIX epoch). e.g.
Ruby 1.9.2p320¶
1.9.2p320 :001 > require 'date'
1.9.2p320 :002 > require 'time'
1.9.2p320 :003 > DateTime.civil(1850).strftime('%s')
=> "-3786825600"
Ruby 1.9.3p194¶
1.9.3p194 :001 > require 'date'
1.9.3p194 :002 > require 'time'
1.9.3p194 :003 > DateTime.civil(1850).strftime('%s')
=> "508141696"
The transition occurs at midnight on 23rd December 1935:
1.9.3p194 :006 > DateTime.civil(1935, 12, 23, 23, 59, 59).strftime('%s')
=> "1073790847"
1.9.3p194 :007 > DateTime.civil(1935, 12, 24, 0, 0, 0).strftime('%s')
=> "-1073692800"
Dates in the far future seem to be okay:
1.9.3p194 :013 > DateTime.civil(20000000).strftime('%s')
=> "631076872780800"
I've tried tracking it down in date_strftime.c but haven't got very far yet.
Updated by tadf (tadayoshi funaba) over 12 years ago
- Assignee set to tadf (tadayoshi funaba)
Updated by tadf (tadayoshi funaba) over 12 years ago
- Status changed from Open to Closed
Updated by naruse (Yui NARUSE) over 12 years ago
Fixed in r36265.