X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fblosxom-plugins.git;a=blobdiff_plain;f=gavinc%2Fstorydate;h=78c2df15a994ffea7023afa3836cb51e656cce37;hp=35c060bb1bc9f6d501f3a55f96c73e5843b2fb05;hb=ad3af3cccc6f2e50b250bd3ca8d98e2a1a58e994;hpb=8e0324e7a66d95f254920991f60045d12b07e24e diff --git a/gavinc/storydate b/gavinc/storydate index 35c060b..78c2df1 100644 --- a/gavinc/storydate +++ b/gavinc/storydate @@ -2,7 +2,7 @@ # Author(s): Gavin Carr # (based on work by Frank Hecker # and Bob Schumaker ) -# Version: 0.001000 +# Version: 0.002000 # Documentation: See the bottom of this file or type: perldoc storydate package storydate; @@ -20,6 +20,7 @@ use File::stat; my @strftime_modules = qw(Time::Piece Date::Format POSIX); # --------------------------------- +# __END_CONFIG__ # Package variables use vars qw( @@ -29,11 +30,13 @@ use vars qw( $story_mtime_iso8601 $now_rfc822 $now_iso8601 + $latest_rfc822 + $latest_iso8601 %strftime_formats ); %strftime_formats = ( - rfc822 => "%a, %d %b %Y %T %z", + rfc822 => "%a, %d %b %Y %T %z", # ISO 8601 format (localtime, including time zone offset) # Format is YYYY-MM-DDThh:mm:ssTZD per http://www.w3.org/TR/NOTE-datetime iso8601 => "%Y-%m-%dT%T%z", @@ -48,6 +51,22 @@ sub start { 1; } +sub filter { + my ($pkg, $files, $others) = @_; + + # Find the latest publish date in our stories + my $latest_ts = 0; + for (values %$files) { + $latest_ts = $_ if $_ > $latest_ts; + } + + # Format the 'latest' variables + $latest_rfc822 = format_date('rfc822', $latest_ts); + $latest_iso8601 = format_date('iso8601', $latest_ts); + + return 1; +} + sub story { my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_; @@ -206,6 +225,14 @@ The current time in RFC822 format. The current time in ISO8601 format. +=item $latest_rfc822 + +The latest story publication date, in RFC822 format. + +=item $latest_iso8601 + +The latest story publication date, in ISO8601 format. + =back In addition, storydate defines a few subroutines that might be useful