X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fblosxom-plugins.git;a=blobdiff_plain;f=xtaran%2Fdate_rfc822;fp=xtaran%2Fdate_rfc822;h=8911020dc41cb9666a84cff774d0a34e3e9c8192;hp=0000000000000000000000000000000000000000;hb=f411779f855bc712a621b9a3c6103ac9c6732403;hpb=8423e2bd76579f5f032cfb2cee41212ca9699055 diff --git a/xtaran/date_rfc822 b/xtaran/date_rfc822 new file mode 100644 index 0000000..8911020 --- /dev/null +++ b/xtaran/date_rfc822 @@ -0,0 +1,76 @@ +# Blosxom Plugin: date_rfc822 +# Author(s): Axel Beckert , based on 822-date +# Version: 1.0 +# Documentation: See the bottom of this file or type: perldoc date_rfc822 + +package date_rfc822; + +$date; # use as $date_rfc822::date + +use POSIX qw(strftime); + +sub start { + 1; +} + +sub date { + my ($pkg, $path, $date_ref, $mtime, @date_bits) = @_; + +@localtm = localtime ($mtime); +$localtms = localtime ($mtime); +@gmttm = gmtime ($mtime); +$gmttms = gmtime ($mtime); + +if ($localtm[0] != $gmttm[0]) { + die (sprintf ("local timezone differs from GMT by a non-minute interval\n" + . "local time: %s\n" + . "GMT time: %s\n", $localtms, $gmttms)); +} + +$localmin = $localtm[1] + $localtm[2] * 60; +$gmtmin = $gmttm[1] + $gmttm[2] * 60; + +if ((($gmttm[6] + 1) % 7) == $localtm[6]) { + $localmin += 1440; +} elsif ((($gmttm[6] - 1) % 7) == $localtm[6]) { + $localmin -= 1440; +} elsif ($gmttm[6] == $localtm[6]) { + 1; +} else { + die ("822-date: local time offset greater than or equal to 24 hours\n"); +} + +$offset = $localmin - $gmtmin; +$offhour = $offset / 60; +$offmin = abs ($offset % 60); + +if (abs ($offhour) >= 24) { + die ("822-date: local time offset greater than or equal to 24 hours\n"); +} + +$date = sprintf + ( + "%s, %2d %s %d %02d:%02d:%02d %s%02d%02d", + (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$localtm[6]], # day of week + $localtm[3], # day of month + (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$localtm[4]], # month + $localtm[5]+1900, # year + $localtm[2], # hour + $localtm[1], # minute + $localtm[0], # sec + ($offset >= 0) ? '+' : '-',# TZ offset direction + abs ($offhour), # TZ offset hour + $offmin, # TZ offset minute + ) || die "822-date: output error: $!\n"; + + + 1; +} + +1; + +__END__ + +=head1 NAME + +Blosxom Plug-in: date_rfc822