Add entries_timestamp.
[blosxom-plugins.git] / xtaran / date_rfc822
blob8911020dc41cb9666a84cff774d0a34e3e9c8192
1 # Blosxom Plugin: date_rfc822
2 # Author(s): Axel Beckert <abe@deuxchevaux.org>, based on 822-date
3 # Version: 1.0
4 # Documentation: See the bottom of this file or type: perldoc date_rfc822
6 package date_rfc822;
8 $date; # use as $date_rfc822::date
10 use POSIX qw(strftime);
12 sub start {
13   1;
16 sub date {
17   my ($pkg, $path, $date_ref, $mtime, @date_bits) = @_;
19 @localtm = localtime ($mtime);
20 $localtms = localtime ($mtime);
21 @gmttm = gmtime ($mtime);
22 $gmttms = gmtime ($mtime);
24 if ($localtm[0] != $gmttm[0]) {
25     die (sprintf ("local timezone differs from GMT by a non-minute interval\n"
26                  . "local time: %s\n"
27                  . "GMT time: %s\n", $localtms, $gmttms));
30 $localmin = $localtm[1] + $localtm[2] * 60;
31 $gmtmin = $gmttm[1] + $gmttm[2] * 60;
33 if ((($gmttm[6] + 1) % 7) == $localtm[6]) {
34     $localmin += 1440;
35 } elsif ((($gmttm[6] - 1) % 7) == $localtm[6]) {
36     $localmin -= 1440;
37 } elsif ($gmttm[6] == $localtm[6]) {
38     1;
39 } else {
40     die ("822-date: local time offset greater than or equal to 24 hours\n");
43 $offset = $localmin - $gmtmin;
44 $offhour = $offset / 60;
45 $offmin = abs ($offset % 60);
47 if (abs ($offhour) >= 24) { 
48     die ("822-date: local time offset greater than or equal to 24 hours\n");
51 $date = sprintf 
52     (
53      "%s, %2d %s %d %02d:%02d:%02d %s%02d%02d",
54      (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$localtm[6]], # day of week
55      $localtm[3],               # day of month
56      (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$localtm[4]], # month
57      $localtm[5]+1900,          # year
58      $localtm[2],               # hour
59      $localtm[1],               # minute
60      $localtm[0],               # sec
61      ($offset >= 0) ? '+' : '-',# TZ offset direction
62      abs ($offhour),            # TZ offset hour
63      $offmin,                   # TZ offset minute
64      ) || die "822-date: output error: $!\n";
67   1;
72 __END__
74 =head1 NAME
76 Blosxom Plug-in: date_rfc822