1N/Apackage Time::localtime;
1N/Ause strict;
1N/Ause 5.006_001;
1N/A
1N/Ause Time::tm;
1N/A
1N/Aour(@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION);
1N/ABEGIN {
1N/A use Exporter ();
1N/A @ISA = qw(Exporter Time::tm);
1N/A @EXPORT = qw(localtime ctime);
1N/A @EXPORT_OK = qw(
1N/A $tm_sec $tm_min $tm_hour $tm_mday
1N/A $tm_mon $tm_year $tm_wday $tm_yday
1N/A $tm_isdst
1N/A );
1N/A %EXPORT_TAGS = ( FIELDS => [ @EXPORT_OK, @EXPORT ] );
1N/A $VERSION = 1.02;
1N/A}
1N/Ause vars @EXPORT_OK;
1N/A
1N/Asub populate (@) {
1N/A return unless @_;
1N/A my $tmob = Time::tm->new();
1N/A @$tmob = (
1N/A $tm_sec, $tm_min, $tm_hour, $tm_mday,
1N/A $tm_mon, $tm_year, $tm_wday, $tm_yday,
1N/A $tm_isdst )
1N/A = @_;
1N/A return $tmob;
1N/A}
1N/A
1N/Asub localtime (;$) { populate CORE::localtime(@_ ? shift : time)}
1N/Asub ctime (;$) { scalar CORE::localtime(@_ ? shift : time) }
1N/A
1N/A1;
1N/A
1N/A__END__
1N/A
1N/A=head1 NAME
1N/A
1N/ATime::localtime - by-name interface to Perl's built-in localtime() function
1N/A
1N/A=head1 SYNOPSIS
1N/A
1N/A use Time::localtime;
1N/A printf "Year is %d\n", localtime->year() + 1900;
1N/A
1N/A $now = ctime();
1N/A
1N/A use Time::localtime;
1N/A use File::stat;
1N/A $date_string = ctime(stat($file)->mtime);
1N/A
1N/A=head1 DESCRIPTION
1N/A
1N/AThis module's default exports override the core localtime() function,
1N/Areplacing it with a version that returns "Time::tm" objects.
1N/AThis object has methods that return the similarly named structure field
1N/Aname from the C's tm structure from F<time.h>; namely sec, min, hour,
1N/Amday, mon, year, wday, yday, and isdst.
1N/A
1N/AYou may also import all the structure fields directly into your namespace
1N/Aas regular variables using the :FIELDS import tag. (Note that this still
1N/Aoverrides your core functions.) Access these fields as
1N/Avariables named with a preceding C<tm_> in front their method names.
1N/AThus, C<$tm_obj-E<gt>mday()> corresponds to $tm_mday if you import
1N/Athe fields.
1N/A
1N/AThe ctime() function provides a way of getting at the
1N/Ascalar sense of the original CORE::localtime() function.
1N/A
1N/ATo access this functionality without the core overrides,
1N/Apass the C<use> an empty import list, and then access
1N/Afunction functions with their full qualified names.
1N/AOn the other hand, the built-ins are still available
1N/Avia the C<CORE::> pseudo-package.
1N/A
1N/A=head1 NOTE
1N/A
1N/AWhile this class is currently implemented using the Class::Struct
1N/Amodule to build a struct-like class, you shouldn't rely upon this.
1N/A
1N/A=head1 AUTHOR
1N/A
1N/ATom Christiansen