1 package Time::localtime;
6 our(@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION);
9 @ISA = qw(Exporter Time::tm);
10 @EXPORT = qw(localtime ctime);
12 $tm_sec $tm_min $tm_hour $tm_mday
13 $tm_mon $tm_year $tm_wday $tm_yday
16 %EXPORT_TAGS = ( FIELDS => [ @EXPORT_OK, @EXPORT ] );
23 my $tmob = Time::tm->new();
25 $tm_sec, $tm_min, $tm_hour, $tm_mday,
26 $tm_mon, $tm_year, $tm_wday, $tm_yday,
32 sub localtime (;$) { populate CORE::localtime(@_ ? shift : time)}
33 sub ctime (;$) { scalar CORE::localtime(@_ ? shift : time) }
41 Time::localtime - by-name interface to Perl's built-in localtime() function
46 printf "Year is %d\n", localtime->year() + 1900;
52 $date_string = ctime(stat($file)->mtime);
56 This module's default exports override the core localtime() function,
57 replacing it with a version that returns "Time::tm" objects.
58 This object has methods that return the similarly named structure field
59 name from the C's tm structure from F<time.h>; namely sec, min, hour,
60 mday, mon, year, wday, yday, and isdst.
62 You may also import all the structure fields directly into your namespace
63 as regular variables using the :FIELDS import tag. (Note that this still
64 overrides your core functions.) Access these fields as
65 variables named with a preceding C<tm_> in front their method names.
66 Thus, C<$tm_obj-E<gt>mday()> corresponds to $tm_mday if you import
69 The ctime() function provides a way of getting at the
70 scalar sense of the original CORE::localtime() function.
72 To access this functionality without the core overrides,
73 pass the C<use> an empty import list, and then access
74 function functions with their full qualified names.
75 On the other hand, the built-ins are still available
76 via the C<CORE::> pseudo-package.
80 While this class is currently implemented using the Class::Struct
81 module to build a struct-like class, you shouldn't rely upon this.