This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Limit @ISA to actual DBM in AnyDBM
[perl5.git] / lib / Time / gmtime.pm
CommitLineData
36477c24 1package Time::gmtime;
2use strict;
3use Time::tm;
4
5BEGIN {
6 use Exporter ();
7 use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
8 @ISA = qw(Exporter Time::tm);
9 @EXPORT = qw(gmtime gmctime);
10 @EXPORT_OK = qw(
11 $tm_sec $tm_min $tm_hour $tm_mday
12 $tm_mon $tm_year $tm_wday $tm_yday
13 $tm_isdst
14 );
15 %EXPORT_TAGS = ( FIELDS => [ @EXPORT_OK, @EXPORT ] );
16}
17use vars @EXPORT_OK;
18
19sub populate (@) {
20 return unless @_;
21 my $tmob = Time::tm->new();
22 @$tmob = (
23 $tm_sec, $tm_min, $tm_hour, $tm_mday,
24 $tm_mon, $tm_year, $tm_wday, $tm_yday,
25 $tm_isdst )
26 = @_;
27 return $tmob;
28}
29
30sub gmtime (;$) { populate CORE::gmtime(shift||time)}
31sub gmctime (;$) { scalar CORE::gmtime(shift||time)}
32
331;
34__END__
35
36=head1 NAME
37
2ae324a7 38Time::gmtime - by-name interface to Perl's built-in gmtime() function
36477c24 39
40=head1 SYNOPSIS
41
42 use Time::gmtime;
43 $gm = gmtime();
44 printf "The day in Greenwich is %s\n",
45 (qw(Sun Mon Tue Wed Thu Fri Sat Sun))[ gm->wday() ];
46
47 use Time::gmtime w(:FIELDS;
48 printf "The day in Greenwich is %s\n",
49 (qw(Sun Mon Tue Wed Thu Fri Sat Sun))[ gm_wday() ];
50
51 $now = gmctime();
52
53 use Time::gmtime;
54 use File::stat;
55 $date_string = gmctime(stat($file)->mtime);
56
57=head1 DESCRIPTION
58
59This module's default exports override the core gmtime() function,
60replacing it with a version that returns "Time::tm" objects.
61This object has methods that return the similarly named structure field
62name from the C's tm structure from F<time.h>; namely sec, min, hour,
63mday, mon, year, wday, yday, and isdst.
64
65You may also import all the structure fields directly into your namespace
66as regular variables using the :FIELDS import tag. (Note that this
67still overrides your core functions.) Access these fields as variables
68named with a preceding C<tm_> in front their method names. Thus,
69C<$tm_obj-E<gt>mday()> corresponds to $tm_mday if you import the fields.
70
71The gmctime() funtion provides a way of getting at the
72scalar sense of the original CORE::gmtime() function.
73
74To access this functionality without the core overrides,
75pass the C<use> an empty import list, and then access
76function functions with their full qualified names.
77On the other hand, the built-ins are still available
78via the C<CORE::> pseudo-package.
79
80=head1 NOTE
81
82While this class is currently implemented using the Class::Template
83module to build a struct-like class, you shouldn't rely upon this.
84
85=head1 AUTHOR
86
87Tom Christiansen