[Rt-commit] rt branch, 4.0-trunk, updated. rt-4.0.18rc1-4-gb158654
Alex Vandiver
alexmv at bestpractical.com
Fri Oct 4 01:50:24 EDT 2013
The branch, 4.0-trunk has been updated
via b1586549149d86e718a1a7406752c830aa93b587 (commit)
via 348fb134aabdc6dfbac6539c43123946cdbad031 (commit)
from b9cb82bf28b1e5e9b4a22c772bf619a824de345f (commit)
Summary of changes:
lib/RT/Date.pm | 2 +-
t/api/date.t | 24 ++++++++++++------------
t/web/helpers-http-cache-headers.t | 6 +++---
3 files changed, 16 insertions(+), 16 deletions(-)
- Log -----------------------------------------------------------------
commit 348fb134aabdc6dfbac6539c43123946cdbad031
Author: Patrick Cherry <patrick at bytemark.co.uk>
Date: Tue Aug 7 17:13:00 2012 +0200
Update RT::Date RFC2822 to use two-digit month days, fixing RFC 2616 output
While RFC2822 specifies 1*2DIGIT as the 'day' specification [1] (for
which the previous implementation was not incorrect), RFC2616 specifies
2DIGIT [2]. Since the RFC2822 implementation is used in generating the
RFC2616 output, this led to improper date strings when in the first nine
days of each month.
Pad the 'day' portion with 0s as necessary, as required by RFC2616 and
allowed by RFC2822.
Fixes http://issues.bestpractical.com/Ticket/Display.html?id=20701
[1] http://tools.ietf.org/html/rfc2822#section-3.3
[2] http://tools.ietf.org/html/rfc2616#section-3.3.1
diff --git a/lib/RT/Date.pm b/lib/RT/Date.pm
index 284cef5..9336fae 100644
--- a/lib/RT/Date.pm
+++ b/lib/RT/Date.pm
@@ -843,7 +843,7 @@ sub RFC2822 {
my ($date, $time) = ('','');
$date .= "$DAYS_OF_WEEK[$wday], " if $args{'DayOfWeek'} && $args{'Date'};
- $date .= "$mday $MONTHS[$mon] $year" if $args{'Date'};
+ $date .= sprintf("%02d %s %04d", $mday, $MONTHS[$mon], $year) if $args{'Date'};
if ( $args{'Time'} ) {
$time .= sprintf("%02d:%02d", $hour, $min);
diff --git a/t/api/date.t b/t/api/date.t
index a830f7f..cc1c694 100644
--- a/t/api/date.t
+++ b/t/api/date.t
@@ -94,7 +94,7 @@ my $current_user;
'1970-01-01T00:00:00Z',
"W3CDTF format with defaults");
is($date->Get(Format =>'RFC2822'),
- 'Thu, 1 Jan 1970 00:00:00 +0000',
+ 'Thu, 01 Jan 1970 00:00:00 +0000',
"RFC2822 format with defaults");
is($date->Get(Format =>'LocalizedDateTime'),
'Thu, Jan 1, 1970 12:00:00 AM',
@@ -107,7 +107,7 @@ my $current_user;
'1970-01-01',
"W3CDTF format without time part");
is($date->RFC2822(Time => 0),
- 'Thu, 1 Jan 1970',
+ 'Thu, 01 Jan 1970',
"RFC2822 format without time part");
is($date->LocalizedDateTime(Time => 0),
'Thu, Jan 1, 1970',
@@ -137,7 +137,7 @@ my $current_user;
"RFC2822 format without date part and seconds");
is($date->RFC2822(DayOfWeek => 0),
- '1 Jan 1970 00:00:00 +0000',
+ '01 Jan 1970 00:00:00 +0000',
"RFC2822 format without 'day of week' part");
is($date->RFC2822(DayOfWeek => 0, Date => 0),
'00:00:00 +0000',
@@ -163,7 +163,7 @@ my $current_user;
'1970-01-01',
"'Date' method, W3CDTF format");
is($date->Date(Format => 'RFC2822'),
- 'Thu, 1 Jan 1970',
+ 'Thu, 01 Jan 1970',
"'Date' method, RFC2822 format");
is($date->Date(Time => 1),
'1970-01-01',
@@ -195,7 +195,7 @@ my $current_user;
'1970-01-01T00:00:00Z',
"'DateTime' method, W3CDTF format");
is($date->DateTime(Format =>'RFC2822'),
- 'Thu, 1 Jan 1970 00:00:00 +0000',
+ 'Thu, 01 Jan 1970 00:00:00 +0000',
"'DateTime' method, RFC2822 format");
is($date->DateTime(Date => 0, Time => 0),
'1970-01-01 00:00:00',
@@ -209,14 +209,14 @@ my $current_user;
$date->Set( Format => 'ISO', Timezone => 'utc', Value => '2005-01-01 15:10:00' );
is($date->ISO( Timezone => 'user' ), '2005-01-01 18:10:00', "ISO");
is($date->W3CDTF( Timezone => 'user' ), '2005-01-01T18:10:00+03:00', "W3C DTF");
- is($date->RFC2822( Timezone => 'user' ), 'Sat, 1 Jan 2005 18:10:00 +0300', "RFC2822");
+ is($date->RFC2822( Timezone => 'user' ), 'Sat, 01 Jan 2005 18:10:00 +0300', "RFC2822");
# DST
$date = RT::Date->new( $current_user );
$date->Set( Format => 'ISO', Timezone => 'utc', Value => '2005-07-01 15:10:00' );
is($date->ISO( Timezone => 'user' ), '2005-07-01 19:10:00', "ISO");
is($date->W3CDTF( Timezone => 'user' ), '2005-07-01T19:10:00+04:00', "W3C DTF");
- is($date->RFC2822( Timezone => 'user' ), 'Fri, 1 Jul 2005 19:10:00 +0400', "RFC2822");
+ is($date->RFC2822( Timezone => 'user' ), 'Fri, 01 Jul 2005 19:10:00 +0400', "RFC2822");
}
{ # negative timezone
@@ -225,14 +225,14 @@ my $current_user;
$date->Set( Format => 'ISO', Timezone => 'utc', Value => '2005-01-01 15:10:00' );
is($date->ISO( Timezone => 'user' ), '2005-01-01 10:10:00', "ISO");
is($date->W3CDTF( Timezone => 'user' ), '2005-01-01T10:10:00-05:00', "W3C DTF");
- is($date->RFC2822( Timezone => 'user' ), 'Sat, 1 Jan 2005 10:10:00 -0500', "RFC2822");
+ is($date->RFC2822( Timezone => 'user' ), 'Sat, 01 Jan 2005 10:10:00 -0500', "RFC2822");
# DST
$date = RT::Date->new( $current_user );
$date->Set( Format => 'ISO', Timezone => 'utc', Value => '2005-07-01 15:10:00' );
is($date->ISO( Timezone => 'user' ), '2005-07-01 11:10:00', "ISO");
is($date->W3CDTF( Timezone => 'user' ), '2005-07-01T11:10:00-04:00', "W3C DTF");
- is($date->RFC2822( Timezone => 'user' ), 'Fri, 1 Jul 2005 11:10:00 -0400', "RFC2822");
+ is($date->RFC2822( Timezone => 'user' ), 'Fri, 01 Jul 2005 11:10:00 -0400', "RFC2822");
}
warning_like
@@ -456,12 +456,12 @@ my $year = (localtime(time))[5] + 1900;
RT->Config->Set( DateTimeFormat => 'RFC2822' );
$date->Unix(1);
- is($date->AsString, 'Thu, 1 Jan 1970 00:00:01 +0000', "correct string");
+ is($date->AsString, 'Thu, 01 Jan 1970 00:00:01 +0000', "correct string");
RT->Config->Set( DateTimeFormat => { Format => 'RFC2822', Seconds => 0 } );
$date->Unix(1);
- is($date->AsString, 'Thu, 1 Jan 1970 00:00 +0000', "correct string");
- is($date->AsString(Seconds => 1), 'Thu, 1 Jan 1970 00:00:01 +0000', "correct string");
+ is($date->AsString, 'Thu, 01 Jan 1970 00:00 +0000', "correct string");
+ is($date->AsString(Seconds => 1), 'Thu, 01 Jan 1970 00:00:01 +0000', "correct string");
}
{ # DurationAsString
diff --git a/t/web/helpers-http-cache-headers.t b/t/web/helpers-http-cache-headers.t
index d4d201d..420a02d 100644
--- a/t/web/helpers-http-cache-headers.t
+++ b/t/web/helpers-http-cache-headers.t
@@ -57,15 +57,15 @@ diag "set up expected date headers";
$expected = {
Autocomplete => {
'Cache-Control' => 'max-age=120, private',
- 'Expires' => 'Fri, 5 Apr 2013 15:30:19 GMT',
+ 'Expires' => 'Fri, 05 Apr 2013 15:30:19 GMT',
},
NoAuth => {
'Cache-Control' => 'max-age=2592000, public',
- 'Expires' => 'Sun, 5 May 2013 15:28:19 GMT',
+ 'Expires' => 'Sun, 05 May 2013 15:28:19 GMT',
},
default => {
'Cache-Control' => 'no-cache',
- 'Expires' => 'Fri, 5 Apr 2013 15:28:19 GMT',
+ 'Expires' => 'Fri, 05 Apr 2013 15:28:19 GMT',
},
};
commit b1586549149d86e718a1a7406752c830aa93b587
Merge: b9cb82b 348fb13
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Oct 4 01:49:06 2013 -0400
Merge branch '4.0/two-digit-rfc2616-date' into 4.0-trunk
Closes github pull request #34
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list