When
{DisplayTimeValues} is set to
servertime
, mailnotify script generates
Date:
header that is not RFC-compliant: time zone name is invalid, e.g.
Date: Fri, 22 Dec 2006 06:59:47 Local
.
I think it would be ok to always use UTC format for
http
and
email
in
TWiki::Time::formatTime
.
The date is entered in a mail several times, using different code. It's not clear which date you are referring to. Assuming it is the date in the mail header (the Date: field) that is giving offence, then that date is generated by
TWiki::Time::formatTime
. The expanded string is
$email
which expands identically to the
$http
format. This code
claims
# HTTP header format, e.g. "Thu, 23 Jul 1998 07:21:56 EST"
# - based on RFC 2616/1123 and HTTP::Date; also used
# by TWiki::Net for Date header in emails.
I modified the summary to reflect that this is not specific to mailnotify, but will impact any use of
$http
or
$email
in a call to
TWiki::Time::formatTime
.
Can you be more specific about what is giving offence? Is the the "Local" for the timezone? Which RFC are you referring to? How would you rewrite that code (in
lib/TWiki/Time.pm
) to work as you expect?
CC
i am referring to the message header field named "Date".
"Local" is not valid time zone specification according to rfc-2822. (and "GMT" is obsolete time zone specification, by the way.)
one possible solution is change line 214 of Time.pm to this:
my $tz_str = ( $outputTimeZone eq 'servertime' ) ? '-0000' : '+0000';
(that is rfc2822-compliant way to say "Local").
another option is to force UTC time for message headers, as i initially suggested:
--- Time.pm.orig 2006-10-25 04:16:05.000000000 +0300
+++ Time.pm 2006-12-28 07:16:47.406250000 +0200
@@ -167,7 +167,9 @@
$outputTimeZone ||= $TWiki::cfg{DisplayTimeValues};
my( $sec, $min, $hour, $day, $mon, $year, $wday);
- if( $outputTimeZone eq 'servertime' ) {
+ if( ( $outputTimeZone eq 'servertime' )
+ and ( $formatString !~ /http|email/i )
+ ) {
( $sec, $min, $hour, $day, $mon, $year, $wday ) =
localtime( $epochSeconds );
} else {
@@ -183,7 +185,7 @@
# HTTP header format, e.g. "Thu, 23 Jul 1998 07:21:56 EST"
# - based on RFC 2616/1123 and HTTP::Date; also used
# by TWiki::Net for Date header in emails.
- $formatString = '$wday, $day $month $year $hour:$min:$sec $tz';
+ $formatString = '$wday, $day $month $year $hour:$min:$sec +0000';
} elsif ( $formatString =~ /iso/i ) {
# ISO Format, see spec at http://www.w3.org/TR/NOTE-datetime
# e.g. "2002-12-31T19:30:12Z"
--
als
OK, thanks. This is important to get right, so I think the fix should be in the next release. Unfortunately it just missed 4.1, but could make it for 4.1.1
Analysed, so setting to Actioning. Anyone please pick this up and apply the patch.
CC
OK, I did it slightly differently in the end, but to the same effect.
CC