From: Gavin Carr Date: Mon, 29 Oct 2007 22:31:41 +0000 (+0000) Subject: Fix iso8601 format in storydate. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=2ef9a451e937ef9fb4708c5ce0e7b33d51693e3d;p=matthijs%2Fupstream%2Fblosxom-plugins.git Fix iso8601 format in storydate. --- diff --git a/gavinc/storydate b/gavinc/storydate index 0341ea0..35c060b 100644 --- a/gavinc/storydate +++ b/gavinc/storydate @@ -36,7 +36,7 @@ use vars qw( 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", + iso8601 => "%Y-%m-%dT%T%z", ); sub start { @@ -93,12 +93,20 @@ sub get_story_dates { sub format_date { my ($format, $time, $use_gmtime) = @_; return unless $format; + + my $date = ''; if ($format =~ m/%/) { - return strftime($format, $time, $use_gmtime); + $date = strftime($format, $time, $use_gmtime); } elsif ($strftime_formats{ $format }) { - return strftime($strftime_formats{ $format }, $time, $use_gmtime); + $date = strftime($strftime_formats{ $format }, $time, $use_gmtime); + } + # Hack to handle the fact that ISO8601 dates require a : in the timezone, which strftime doesn't support + if ($format eq 'iso8601') { + $date =~ s/(\d)(\d{2})$/$1:$2/; } + + return $date; } # strftime wrapper, using the first strftime() it finds in @strftime_modules