[Home]WikiBugs/RssDateAndTimeZone

UseModWiki | WikiBugs | RecentChanges | Preferences

I will probably add the config option below (RssTimeZone? to 1.1.
(Sorry, I'm not good at English)

In GetRssRcLinke? function, "dc:date" of rss output is made by the code,

  $date = sprintf("%4d-%02d-%02dT%02d:%02d:%02d+%02d:00",
          $year, $mon+1, $mday, $hour, $min, $sec, $TimeZoneOffset/(60*60));

However, it is correct only if "Server's clock" is set to GMT.

For example, the server in which my homepage is located in Korea. It's clock is set to +9:00. So every guests (all of them are Korean) of my homepage set their TimeZoneOffset in Preferences to zero . If a page is modified on 10:00 of server clock (= 1:00 GMT), then rss output is:

  <dc:date>2003-10-03T10:00:00+00:00</dc:date>

Therefore, a rss aggregator program such as "Feed Demon" mistakes the page was modified on "10:00 GMT", adds +9 due to the locale of my PC, and says "the page is modified on 19:00"

To fix this problem, I added a new config variable, "RssTimeZone? = 9", which means the timezone of server clock. And changed the code to

  $date = sprintf("%4d-%02d-%02dT%02d:%02d:%02d+%02d:00",
          $year, $mon+1, $mday, $hour, $min, $sec, ($TimeZoneOffset/(60*60) + $RssTimeZone));

I can't guess whether this change make a new problem (I don't know about rss). Any advice will be appreciated.


I don't know much about RSS, but I can see how this could be a problem. I want to think about this more, but I think this option will be in 1.1. Thank you for the bug report. --CliffordAdams
The above code doesn't quite work when the offset is negative. How about something along the lines of:
  my $gmt_offset = $TimeZoneOffset/(60*60) + $RssTimeZone;
  my $plusminus = $gmt_offset > 0 ? '+' : '-';
  $date = sprintf("%4d-%02d-%02dT%02d:%02d:%02d%d%02d:00",
          $year, $mon+1, $mday, $hour, $min, $sec, $plusminus, abs($gmt_offset) );

Also.. for daylight savings time, it's a pain to have to manually change the time zone offset parameter twice a year (not to mention figuring out which way it needs to be adjusted!) Perhaps there's a way to get the time info from the system?

-- Anonymous

I think the above submission tries to print '+' or '-' with the printf character specifier %d; how about this:

  my $gmt_offset = $TimeZoneOffset/(60*60) + $RssTimeZone;
  my $plusminus = $gmt_offset > 0 ? '+' : '-';
  $date = sprintf("%4d-%02d-%02dT%02d:%02d:%02d%s%02d:00",
          $year, $mon+1, $mday, $hour, $min, $sec, $plusminus, abs($gmt_offset) );

-- BayleShanks


I just discovered this bug ... an easier solution would be to use gmtime() instead of localtime (and forget manipulating the timestamp by user offset). So the RSS reader should convert to local time of the user, if necessary. Here a diff (line numbers may be not the same as in the official script, since i applied some other patches):

 --- aktivikio.pl        2007-03-08 17:06:04.000000000 +0100
 +++ aktivikio-provo-2007-03-13.pl       2007-03-13 13:53:27.000000000 +0100
 @@ -996,11 +996,10 @@
    }
    $status = (1 == $revision) ? 'new' : 'updated';
    $importance = $isEdit ? 'minor' : 'major';
 -  $timestamp += $TimeZoneOffset;
 -  my ($sec, $min, $hour, $mday, $mon, $year) = localtime($timestamp);
 +  my ($sec, $min, $hour, $mday, $mon, $year) = gmtime($timestamp);
    $year += 1900;
    $date = sprintf("%4d-%02d-%02dT%02d:%02d:%02d+%02d:00",
 -    $year, $mon+1, $mday, $hour, $min, $sec, $TimeZoneOffset/(60*60));
 +    $year, $mon+1, $mday, $hour, $min, $sec, 0 );
    $pagename = &QuoteHtml?($pagename);
    # Write it out longhand
    $item = <<RSS ;

-- Paul Ebermann


UseModWiki | WikiBugs | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited March 13, 2007 12:58 pm by feyd.mathematik.hu-berlin.de (diff)
Search: