• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/Time/H10-Jul-2012-20077

t/H10-Jul-2012-4623

Build.PLH A D10-Jul-20121.1 KiB5344

ChangesH A D10-Jul-201293 52

LICENSEH A D10-Jul-201218 KiB380292

MANIFESTH A D10-Jul-2012164 1413

META.jsonH A D10-Jul-20121 KiB4847

META.ymlH A D10-Jul-2012579 2625

Makefile.PLH A D10-Jul-2012414 1715

READMEH A D10-Jul-20122.6 KiB6147

README

1NAME
2    `Time::timegm' - a UTC version of `mktime()'
3
4SYNOPSIS
5     use Time::timegm qw( timegm );
6
7     my $epoch = timegm( 0, 0, 0, 14, 6-1, 2012-1900 );
8
9     print "2012-06-14 00:00:00 UTC happened at ",
10        scalar localtime($epoch), " localtime\n";
11
12DESCRIPTION
13    The POSIX standard provides three functions for converting between
14    integer epoch values and 6-component "broken-down" time representations.
15    `localtime' and `gmtime' convert an epoch into the 6 components of
16    seconds, minutes, hours, day of month, month and year, in either local
17    timezone or UTC. The `mktime' function converts a local broken-down time
18    into an epoch value. However, `POSIX' does not provide a UTC version of
19    this.
20
21    This module provides a function `timegm' which has this ability.
22
23    Unlike some other CPAN implementations of this behaviour, this version
24    does not re-implement the time handling logic internally. It reuses the
25    `mktime' and `gmtime' functions provided by the system to ensure its
26    results are always consistent with the other functions.
27
28FUNCTIONS
29  $epoch = timegm( $sec, $min, $hour, $mday, $mon, $year )
30    Returns the epoch integer value representing the time given by the 6
31    broken-down components.
32
33    As with `POSIX::mktime' it is *not* required that these values be within
34    their "valid" ranges. This function will normalise values out of range.
35    For example, the 25th hour of a day is normalised to the 1st hour of the
36    following day; or the 0th month is normalised to the 12th month of the
37    preceeding year.
38
39COMPARISON WITH Time::Local
40    The Time::Local module also provides a function called `timegm()' with
41    similar behaviour to this one. The differences are:
42
43    * `Time::timegm::timegm()' handles denormalised values (that is, seconds
44      or minutes outside of the range 0 to 59, hours outside 0 to 23, etc..)
45      by adjusting the next largest unit (such that 61 seconds is 1 second
46      of the next minute, etc). `Time::Local::timegm()' croaks on
47      out-of-range input. `Time::Local' also provides a function
48      `timegm_nocheck()' which does not croak but it is documented that the
49      behavior is unspecified on out-of-range values.
50
51    * `Time::timegm::timegm()' is implemented by a light XS wrapper around
52      the `timegm(3)' or `_mkgmtime(3)' function provided by the platform's
53      C library if such a function is provided, so its behaviour is
54      consistent with the rest of the platform. `Time::Local' re-implements
55      the logic in perl code. `Time::timegm' will fall back to a perl
56      implementation only if the XS one cannot be used.
57
58AUTHOR
59    Paul Evans <leonerd@leonerd.org.uk>
60
61