Skip Menu |

This queue is for tickets about the Time-y2038 CPAN distribution.

Report information
The Basics
Id: 59811
Status: open
Priority: 0/
Queue: Time-y2038

People
Owner: Nobody in particular
Requestors: Deepjyot_Singh [...] dell.com
Cc:
AdminCc:

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



Subject: Time-y2038 -- Giving Incorrect Date
Date: Thu, 29 Jul 2010 15:42:13 +0530
To: "bug-Time-y2038 [...] rt.cpan.org" <bug-Time-y2038 [...] rt.cpan.org>
From: "Singh, Deepjyot" <Deepjyot_Singh [...] dell.com>
Hi, I am trying to print a date in the year 2040 using the module Time::y2038 after setting my system date to the year 2040 as you can see in the screenshot below. I have the following commands in my script and it is giving an incorrect output. Request you to look into this ASAP. [cid:image001.jpg@01ECD39C.563C8B10] Script - use Time::y2038::Everywhere; print "\nTime is - ".localtime(time); Output - D:\>perl date.pl Time is - Sat Jun 25 09:10:28 1904 Thanks & Regards, Deepjyot Singh Dell | Catholic Healthcare West Business: +91 120 2432750 x6290 Cell: +91 9990 200 500 E-mail: Deepjyot_Singh@dell.com<mailto:Sachin_Rastogi@dell.com>
Download image001.jpg
image/jpeg 15.2k
image001.jpg
Subject: Re: [rt.cpan.org #59811] Time-y2038 -- Giving Incorrect Date
Date: Thu, 29 Jul 2010 11:37:43 -0700
To: bug-Time-y2038 [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
On 2010.7.29 3:12 AM, Singh, Deepjyot via RT wrote: Show quoted text
> I am trying to print a date in the year 2040 using the module Time::y2038 > after setting my system date to the year 2040 as you can see in the screenshot > below. I have the following commands in my script and it is giving an incorrect > output. Request you to look into this ASAP.
I suspect what's happened is by moving the system clock after 2038 you triggered the 2038 bug in time(). If you print time() it will probably be negative. Time::y2038 can't do anything much about a 32 bit system clock, that's the only way it knows what time it is. [1] The only condition when this will actually be a problem is after Jan 18, 2038 at which point I hope you're not still using a 32 bit Perl. If you just plug in a future time as a regular integer it will work. use Time::y2038::Everywhere; print "\nTime is - ".localtime(2**33); If you want to know what time it will be at a certain date after 2038 you can use timelocal(). use Time::y2038; print "\nTime on Jan 1st, 2040 is ".timelocal(0,0,0,1,0,2040-1900); Or you can use the more pleasant and y2038 free DateTime. [1] Time::y2038 could override time(), guess that a negative time is wrong and reinterpret the result, similar to a lot of y2k fixes. I'll get around to implementing that around 2032. :) -- The mind is a terrible thing, and it must be stopped.