Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.4 KiB

  1. package Time::localtime;
  2. use strict;
  3. use Time::tm;
  4. use 5.005_64;
  5. our(@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION);
  6. BEGIN {
  7. use Exporter ();
  8. @ISA = qw(Exporter Time::tm);
  9. @EXPORT = qw(localtime ctime);
  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. $VERSION = 1.01;
  17. }
  18. use vars @EXPORT_OK;
  19. sub 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. sub localtime (;$) { populate CORE::localtime(@_ ? shift : time)}
  30. sub ctime (;$) { scalar CORE::localtime(@_ ? shift : time) }
  31. 1;
  32. __END__
  33. =head1 NAME
  34. Time::localtime - by-name interface to Perl's built-in localtime() function
  35. =head1 SYNOPSIS
  36. use Time::localtime;
  37. printf "Year is %d\n", localtime->year() + 1900;
  38. $now = ctime();
  39. use Time::localtime;
  40. use File::stat;
  41. $date_string = ctime(stat($file)->mtime);
  42. =head1 DESCRIPTION
  43. This module's default exports override the core localtime() function,
  44. replacing it with a version that returns "Time::tm" objects.
  45. This object has methods that return the similarly named structure field
  46. name from the C's tm structure from F<time.h>; namely sec, min, hour,
  47. mday, mon, year, wday, yday, and isdst.
  48. You may also import all the structure fields directly into your namespace
  49. as regular variables using the :FIELDS import tag. (Note that this still
  50. overrides your core functions.) Access these fields as
  51. variables named with a preceding C<tm_> in front their method names.
  52. Thus, C<$tm_obj-E<gt>mday()> corresponds to $tm_mday if you import
  53. the fields.
  54. The ctime() function provides a way of getting at the
  55. scalar sense of the original CORE::localtime() function.
  56. To access this functionality without the core overrides,
  57. pass the C<use> an empty import list, and then access
  58. function functions with their full qualified names.
  59. On the other hand, the built-ins are still available
  60. via the C<CORE::> pseudo-package.
  61. =head1 NOTE
  62. While this class is currently implemented using the Class::Struct
  63. module to build a struct-like class, you shouldn't rely upon this.
  64. =head1 AUTHOR
  65. Tom Christiansen