Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime CPAN distribution.

Report information
The Basics
Id: 77719
Status: resolved
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: chansen [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.75



Subject: DateTime returns incorrect epoch for years between 1..999 (inclusive)
DateTime returns incorrect epoch for years between 1..999 (inclusive). The bug or feature lies within Time::Local's rolling behavior. From Time::Local's docs: "Years in the range 0..99 are interpreted as shorthand for years in the rolling "current century," defined as 50 years on either side of the current year. Thus, today, in 1999, 0 would refer to 2000, and 45 to 2045, but 55 would refer to 1955." "Years in the range 100..999 are interpreted as offset from 1900, so that 112 indicates 2012. This rule also applies to years less than zero (but see note below regarding date range)." Returned epocs: $ perl -MDateTime -e 'printf "%d (Y: %d)\n", DateTime->new(year => $_)->epoch, $_ for (1, 99, 100, 999)' 978307200 (Y: 1) 915148800 (Y: 99) 946684800 (Y: 100) 29316470400 (Y: 999) Expected epocs: $ perl -MDateTime -e 'printf "%d (Y: %d)\n", DateTime->new(year => $_)->utc_rd_as_seconds - 62135683200, $_ for (1, 99, 100, 999)' -62135596800 (Y: 1) -59042995200 (Y: 99) -59011459200 (Y: 100) -30641760000 (Y: 999) The DateTime::epoch could be replaced with: sub DateTime::epoch { ($_[0]->{utc_rd_days} - 719163) * SECONDS_PER_DAY + $_[0]->{utc_rd_secs}; } -- chansen