On 30 Aug 2004, at 8:15 PM, David Ledger wrote:
Can anyone explain the following? (the difference in commands is the year spec.)

[EMAIL PROTECTED]: perl -e 'use Time::Local;print ( (localtime(timelocal(0, 0, 0, 1, 1, 55)))[6], "\n");'
2
[EMAIL PROTECTED]: perl -e 'use Time::Local;print ( (localtime(timelocal(0, 0, 0, 1, 1, 54)))[6], "\n");'
Cannot handle date (0, 0, 0, 1, 1, 2054) at -e line 1
[EMAIL PROTECTED]:


All years I've tried > 55 are Ok; all years I've tried < 54 fail.

As Sherm has pointed out, it's due to the two-digit year wrap around. (Remember the so-called Millennium bug? That's what you're perpetuating in the above code)


Your best bet for anything to do with dates and times is to use the DateTime modules. They work on all platforms and comprehensively handle any date and time you can throw at it (right up to $MAXINT-12-31). They handle localization and know all current and historic DST rules back to 1972.

Cheers!
Rick Measham

(disclaimer: I have developed some of the DateTime modules)

Senior Developer
PrintSupply - Print Procurement & Supply Management
18 Greenaway Street VIC 3105
Tel: (03) 9850 3255
Fx: (03) 9850 3277
http://www.printsupply.com.au/




Reply via email to