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: 19849
Status: resolved
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: jt [...] plainblack.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.31
Fixed in: (no value)



Subject: epoch 2040 bug
DateTime does not handle epoch dates larger than 2040, though it does handle them properly when created as a normal object. For example, this program: use DateTime; my $future = time() + 60*60*24*365*40; # roughly 40 years in the future my $dt = DateTime->from_epoch(epoch=>$future); print $dt->strftime('%Y-%m-%d')."\n"; my $dt = DateTime->new(year => 2046, month => 10, day => 16, hour => 16, minute => 12, second => 47, nanosecond => 500000000, time_zone => 'Asia/Taipei' ); print $dt->strftime('%Y-%m-%d')."\n"; Outputs these values: 1910-04-27 2046-10-16 However, both values should be somewhere in 2046. What I don't know is if this is a bug in DateTime or a limitation in Perl integers. If it is a problem with Perl integers, is there a recommended strategy for working around it?
Subject: Re: [rt.cpan.org #19849] epoch 2040 bug
Date: Mon, 12 Jun 2006 17:19:35 -0500 (CDT)
To: Guest via RT <bug-DateTime [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Mon, 12 Jun 2006, Guest via RT wrote: Show quoted text
> What I don't know is if this is a bug in DateTime or a limitation in > Perl integers.
It's a limitation of 32-bit integers. With a 32-bit signed int, time_t overflows sometime in 2038. Show quoted text
> If it is a problem with Perl integers, is there a recommended strategy > for working around it?
Don't use epochs ;) Seriously, if you need to use dates outside the range that can be supported by time_t, you cannot use the epoch. DateTime objects can support a much wider range of dates, as long as you don't try to go to/from an epoch. I'm going to close this bug report. Please send future questions to the datetime@perl.org list. -dave /*=================================================== VegGuide.Org www.BookIRead.com Your guide to all that's veg. My book blog ===================================================*/