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