Subject: | Plugin::Date to accept "T" in ISO8601 dates |
It would nice if Plugin::Date could accept dates with a "T" as the
separator like ISO8601 dates:
2012-09-30T12:59:00
http://en.wikipedia.org/wiki/ISO_8601
Patch is attached.
Subject: | accept-T-in-dates.patch |
--- lib/Template/Plugin/Date.pm.orig 2012-06-27 09:40:47.048774867 +0200
+++ lib/Template/Plugin/Date.pm 2012-06-27 09:40:50.816774945 +0200
@@ -96,11 +96,11 @@
else {
# if $time is numeric, then we assume it's seconds since the epoch
# otherwise, we try to parse it as either a 'Y:M:D H:M:S' or a
# 'H:M:S D:M:Y' string
- my @parts = (split(/(?:\/| |:|-)/, $time));
+ my @parts = (split(/\D/, $time));
if (@parts >= 6) {
if (length($parts[0]) == 4) {
# year is first; assume 'Y:M:D H:M:S'
@date = @parts[reverse 0..5];
--- t/date.t.orig 2012-06-27 09:38:07.196771596 +0200
+++ t/date.t 2012-06-27 09:38:10.100771656 +0200
@@ -259,5 +259,12 @@
[% USE date;
date.format('2001/09/30 12:59:00', '%H:%M')
-%]
-- expect --
12:59
+
+-- test --
+[% USE date;
+ date.format('2001/09/30T12:59:00', '%H:%M')
+-%]
+-- expect --
+12:59