[Rt-commit] rt branch, 4.2/extend-iso-data-format, created. rt-4.2.14-9-gbe31b6a0b
Jim Brandt
jbrandt at bestpractical.com
Wed Jan 24 14:41:14 EST 2018
The branch, 4.2/extend-iso-data-format has been created
at be31b6a0b4e9d23f6fcb64f06fff4c99dbfe98a7 (commit)
- Log -----------------------------------------------------------------
commit 9d8d0c92d366eb027f5c217dc158bdf0d3e96c17
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Wed Jan 24 14:38:21 2018 -0500
Accept an optional T in ISO date format
ISO 8601 allows for a T as part of a combined date
and time format, so accept this when setting an ISO date
format.
diff --git a/lib/RT/Date.pm b/lib/RT/Date.pm
index d11ba4113..e708faa78 100644
--- a/lib/RT/Date.pm
+++ b/lib/RT/Date.pm
@@ -183,8 +183,8 @@ sub Set {
elsif ( $format =~ /^(sql|datemanip|iso)$/ ) {
$args{'Value'} =~ s!/!-!g;
- if ( ( $args{'Value'} =~ /^(\d{4})?(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/ )
- || ( $args{'Value'} =~ /^(\d{4})?(\d\d)(\d\d)(\d\d):(\d\d):(\d\d)$/ )
+ if ( ( $args{'Value'} =~ /^(\d{4})?(\d\d)(\d\d)T?+(\d\d)(\d\d)(\d\d)$/ )
+ || ( $args{'Value'} =~ /^(\d{4})?(\d\d)(\d\d)T?+(\d\d):(\d\d):(\d\d)$/ )
|| ( $args{'Value'} =~ /^(?:(\d{4})-)?(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)$/ )
|| ( $args{'Value'} =~ /^(?:(\d{4})-)?(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)\+00$/ )
) {
commit be31b6a0b4e9d23f6fcb64f06fff4c99dbfe98a7
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Wed Jan 24 14:41:02 2018 -0500
Tests for ISO date format with T delimiter
diff --git a/t/api/date.t b/t/api/date.t
index dd22943c1..80faff7ed 100644
--- a/t/api/date.t
+++ b/t/api/date.t
@@ -300,15 +300,27 @@ my $year = (localtime(time))[5] + 1900;
$date->Set(Format => 'ISO', Value => '20051128151000');
is($date->ISO, '2005-11-28 15:10:00', "YYYYDDMMhhmmss");
+ $date->Set(Format => 'ISO', Value => '20051128T151000');
+ is($date->ISO, '2005-11-28 15:10:00', "YYYYDDMMThhmmss");
+
$date->Set(Format => 'ISO', Value => '1128151000');
is($date->ISO, $year .'-11-28 15:10:00', "DDMMhhmmss");
+ $date->Set(Format => 'ISO', Value => '1128T151000');
+ is($date->ISO, $year .'-11-28 15:10:00', "DDMMThhmmss");
+
$date->Set(Format => 'ISO', Value => '2005112815:10:00');
is($date->ISO, '2005-11-28 15:10:00', "YYYYDDMMhh:mm:ss");
+ $date->Set(Format => 'ISO', Value => '20051128T15:10:00');
+ is($date->ISO, '2005-11-28 15:10:00', "YYYYDDMMThh:mm:ss");
+
$date->Set(Format => 'ISO', Value => '112815:10:00');
is($date->ISO, $year .'-11-28 15:10:00', "DDMMhh:mm:ss");
+ $date->Set(Format => 'ISO', Value => '1128T15:10:00');
+ is($date->ISO, $year .'-11-28 15:10:00', "DDMMThh:mm:ss");
+
warning_like {
$date->Set(Format => 'ISO', Value => '2005-13-28 15:10:00');
} qr/Invalid date/;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list