I am hesitant to upload this to CPAN, because -suuuurely- something like
it already exists. I can't seem to find it though.

-----
Time::mkgmtime(3)     User Contributed Perl Documentation    Time::mkgmtime(3)



NAME
       "Time::mkgmtime" - a UTC version of "mktime()"

SYNOPSIS
        use Time::mkgmtime qw( mkgmtime );

        my $epoch = mkgmtime 0, 0, 0, 14, 6-1, 2012-1900;

        print "2012-06-14 00:00:00 UTC happened at ",
           scalar localtime($epoch), " localtime\n";

DESCRIPTION
       The POSIX standard provides three functions for converting between
       integer epoch values and 6-component "broken-down" time
       representations. "localtime" and "gmtime" convert an epoch into the 6
       components of seconds, minutes, hours, day of month, month and year, in
       either local timezone or UTC. The "mktime" function converts a local
       broken-down time into an epoch value.  However, "POSIX" does not
       provide a UTC version of this.

       This module provides a function "mkgmtime" which has this ability.

       Unlike some other CPAN implementations of this behaviour, this version
       does not re-implement the time handling logic internally. It reuses the
       "mktime" and "gmtime" functions provided by the system to ensure its
       results are always consistent with the other functions.

FUNCTIONS
   $epoch = mkgmtime( $sec, $min, $hour, $mday, $mon, $year )
       Returns the epoch integer value representing the time given by the 6
       broken-down components.

       As with "POSIX::mktime" it is not required that these values be within
       their "valid" ranges. This function will normalise values out of range.
       For example, the 25th hour of a day is normalised to the 1st hour of
       the following day; or the 0th month is normalised to the 12th month of
       the preceeding year.

AUTHOR
       Paul Evans <leon...@leonerd.org.uk>



perl v5.14.2                      2012-06-14                 Time::mkgmtime(3)
-----

I specifically make note of two facts:

 1) This module specifically handles denormalised values like
    POSIX::mktime does; things like 31st Jan == 1st Feb BY DESIGN.

 2) This module uses the system's own datetime functions of mktime(3)
    and gmtime(3); it does not attempt to reinvent them with possibly
    incompatible semantics; mkgmtime is always the inverse of gmtime(3).

If someone can point me at an existing implementation of this, I'll use
that instead of uploading this one. But so far I can't find one, yet it
confuses me that such should still not exist yet.

-- 
Paul "LeoNerd" Evans

leon...@leonerd.org.uk
ICQ# 4135350       |  Registered Linux# 179460
http://www.leonerd.org.uk/

Attachment: signature.asc
Description: Digital signature

Reply via email to