Skip to Content
Programming Perl, 3rd Edition
book

Programming Perl, 3rd Edition

by Larry Wall, Tom Christiansen, Jon Orwant
July 2000
Intermediate to advanced
1104 pages
35h 1m
English
O'Reilly Media, Inc.
Content preview from Programming Perl, 3rd Edition

Dates and Times

Where possible, use the ISO-8601 standard ("YYYY-MM-DD") to represent dates. Strings like "1987-12-18" can be easily converted into a system-specific value with a module like Date::Parse. A list of time and date values (such as that returned by the built-in localtime function) can be converted to a system-specific representation using Time::Local.

The built-in time function will always return the number of seconds since the beginning of the "epoch", but operating systems differ in their opinions of when that was. On many systems, the epoch began on January 1, 1970, at 00:00:00 UTC, but it began 66 years earlier on Macs, and on VMS it began on November 17, 1858, at 00:00:00. So for portable times you may want to calculate an offset for the epoch:

require Time::Local;
$offset = Time::Local::timegm(0, 0, 0, 1, 0, 70);

The value for $offset in Unix and Windows will always be 0, but on Macs and VMS it may be some large number. $offset can then be added to a Unix time value to get what should be the same value on any system.

A system's representation of the time of day and the calendar date can be controlled in widely different ways. Don't assume the time zone is stored in $ENV{TZ}. Even if it is, don't assume that you can control the time zone through that variable.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Perl, 4th Edition

Programming Perl, 4th Edition

Tom Christiansen, brian d foy, Larry Wall, Jon Orwant
Learning Perl, 7th Edition

Learning Perl, 7th Edition

Randal L. Schwartz, brian d foy, Tom Phoenix
Programming the Perl DBI

Programming the Perl DBI

Tim Bunce, Alligator Descartes

Publisher Resources

ISBN: 0596000278Supplemental ContentErrata