[Rt-commit] r7839 - rt/branches/3.7-EXPERIMENTAL/lib/RT

ruz at bestpractical.com ruz at bestpractical.com
Sat May 12 11:05:11 EDT 2007


Author: ruz
Date: Sat May 12 11:05:10 2007
New Revision: 7839

Modified:
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Date.pm

Log:
* implement RFC2616 formatter
* update docs

Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Date.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Date.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Date.pm	Sat May 12 11:05:10 2007
@@ -544,7 +544,7 @@
 
 Formatters may also add own arguments to the list, for example
 in RFC2822 format day of time in output is optional so it
-understand argument C<DayOfTime>.
+understand boolean argument C<DayOfTime>.
 
 =head3 DefaultFormat
 
@@ -659,11 +659,12 @@
 };
 
 
-=head3 RFC2822
+=head3 RFC2822 (MIME)
 
-Returns the object's date and time in RFC2822 format.
+Returns the object's date and time in RFC2822 format,
+for example C<Sun, 06 Nov 1994 08:49:37 +0000>.
 Format is locale independand as required by RFC. Time
-part always has timezone offset.
+part always has timezone offset in digits with sign prefix.
 
 Supports arguments: C<Timezone>, C<Date>, C<Time>, C<DayOfWeek>
 and C<Seconds>. See </Output formatters> for description of
@@ -698,6 +699,45 @@
     return join ' ', grep $_, ($date, $time);
 }
 
+=head3 RFC2616 (HTTP)
+
+Returns the object's date and time in RFC2616 (HTTP/1.1) format,
+for example C<Sun, 06 Nov 1994 08:49:37 GMT>. While the RFC describes
+version 1.1 of HTTP, but the same form date can be used in version 1.0.
+
+Format is fixed length, locale independand and always represented in GMT
+what makes it quite useless for users, but any date in HTTP transfers
+must be presented using this format.
+
+    HTTP-date = rfc1123 | ...
+    rfc1123   = wkday "," SP date SP time SP "GMT"
+    date      = 2DIGIT SP month SP 4DIGIT
+                ; day month year (e.g., 02 Jun 1982)
+    time      = 2DIGIT ":" 2DIGIT ":" 2DIGIT
+                ; 00:00:00 - 23:59:59
+    wkday     = "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat" | "Sun"
+    month     = "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun"
+              | "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec"
+
+Supports arguments: C<Date> and C<Time>, but you should use them only for
+some personal reasons, RFC2616 doesn't define any optional parts.
+See </Output formatters> for description of arguments.
+
+=cut
+
+sub RFC2616 {
+    my $self = shift;
+    my %args = ( Date => 1, Time => 1,
+                 @_,
+                 Timezone => 'utc',
+                 Seconds => 1, DayOfWeek => 1,
+               );
+
+    my $res = $self->RFC2822( @_ );
+    $res =~ s/\s*[+-]\d\d\d\d$/ GMT/ if $args{'Time'};
+    return $res;
+}
+
 sub _SplitOffset {
     my ($self, $offset) = @_;
     my $sign = $offset < 0? '-': '+';


More information about the Rt-commit mailing list