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.

89 lines
2.5 KiB

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