Fix iso8601 format in storydate.
authorGavin Carr <gonzai@users.sourceforge.net>
Mon, 29 Oct 2007 22:31:41 +0000 (22:31 +0000)
committerGavin Carr <gonzai@users.sourceforge.net>
Mon, 29 Oct 2007 22:31:41 +0000 (22:31 +0000)
gavinc/storydate

index 0341ea0d2dc0dd3a4a87f197481fa60802142ee0..35c060bb1bc9f6d501f3a55f96c73e5843b2fb05 100644 (file)
@@ -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
     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 { 
 );
 
 sub start { 
@@ -93,12 +93,20 @@ sub get_story_dates {
 sub format_date {
     my ($format, $time, $use_gmtime) = @_;
     return unless $format;
 sub format_date {
     my ($format, $time, $use_gmtime) = @_;
     return unless $format;
+
+    my $date = '';
     if ($format =~ m/%/) {
     if ($format =~ m/%/) {
-        return strftime($format, $time, $use_gmtime);
+        $date = strftime($format, $time, $use_gmtime);
     }
     elsif ($strftime_formats{ $format }) {
     }
     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
 }
 
 # strftime wrapper, using the first strftime() it finds in @strftime_modules