PapaScott I like big blogs and I cannot lie! 🐘

MT, Time Zones, DST, and RSS

I'm planning to archive my quick links as RSS files and use the Magpie or Onyx PHP libraries to add them to my montly archives. While preparing the files, I was reminded that Movable Type has no concept of daylight savings time. The date and time of the entry is saved in local time, without any indication of time zone or daylight savings time.

You can set a time zone for a blog, but it's just a number between -12 and 12, and is a global preference. It seems only to set the MTBlogTimezone variable, which gets tacked onto the dc:date field in the RSS template. If you go onto daylight savings time, the dc:dates will be off by an hour until you adjust your timezone. And in the fall you have to set it back.

This may not really make any difference when generating web pages, when I want to display local time anyway, but it does make a difference to me when I archive entries to RSS files. There I'd just as soon save the dc:time as UTC, which never springs ahead or falls back. Then when I display the file, I can convert to whatever time zone I want.

So I installed Brad Choate's PerlScript Plugin. Then I can use a couple of lines of perl to convert MT date and time to UTC and print it out as a ISO 8601 string fit for the dc:date field. I could probably make this into a plugin for MT as well. But this is a lot more trouble than it needs to be. MT should be able to keep track of time zones and daylight saving time on its own.

use Time::Local;
my $mytime = timelocal(<$MTEntryDate format=
"('%S', '%M', '%H', '%e', '%m'-1, '%Y'-1900)"$>);
my ($sec,$min,$hour,$mday,$mon,$year,

comments powered by Disqus