Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone know of a module or routine to convert UTC time to something more meaningfull?

Replies are listed 'Best First'.
Re: UTC Time Conversion
by sz (Friar) on May 05, 2003 at 16:07 UTC
Re: UTC Time Conversion
by hardburn (Abbot) on May 05, 2003 at 15:56 UTC

    Perl modules for handling dates are about as numerous as the sands of the sea. Hunt in the Date::, Time::, and DateTime:: module namespaces and you should be able find what you need. Somewhere.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated

Re: UTC Time Conversion
by glivings (Scribe) on May 06, 2003 at 02:13 UTC
    If, by "something more meaningful" you mean local time, you might want to have a look at Date::Parse and it's tremendously useful str2time() function. Once you have your date string converted to epoch seconds, you can do all sorts of manipulations to it:
    use POSIX qw/strftime/; use Date::Parse; $ENV{TZ} = "UTC"; my $utc_date_str = "2003-05-06 02:09:00 UTC"; my $epoch_secs = str2time($utc_date_str); $ENV{TZ} = "Canada/Atlantic"; # set TZ to local my $local_date_str = strftime("%Y-%m-%d %T %Z", localtime($epoch_secs) + ); $ENV{TZ} = "UTC"; # restore TZ to UTC print "$local_date_str\n"; -- OUTPUT: 2003-05-05 23:09:00 ADT

    You might also want to have a look at the other Date:: modules. Most of them are small and fast (except for Date::Manip :-), and the odds are that no matter what you have to do in terms of date manipulation, there already exists a module to solve your problem (at least in part).