dp.cx blog

Posted on

Filed under perl, and time

My employer has a lot of different services; one of these services is called an Email News Alert (EMNA for short). For a long time, these EMNAs were prepared manually by a team of 3 based on articles posted on our sites. A month or so ago, we set out to automate this process, in the end, saving approximately 50 hours a week just in the preparation.

For the first 2 weeks, I ran the automation script on my local Ubuntu box (under cron, of course), so that any problems could be fixed easily. Once we'd determined that there were no more outlying bugs, we moved it to a server. I set up the cron job, and went about my business.

The next day, the automation script ran 5 hours early. I checked, ensured that my user TZ was EST/EDT (the content that gets pulled is based on a cutoff time), and re-ran the script 5 hours later. The next day, the same thing happened. I hopped on IRC, chatted with some folks, and determined that cron jobs always run based on the system time. I guess all the other servers I'd ever worked on were set with a system TZ that matched my local TZ, so things ran smoothly. This box had a system TZ of UTC.

Now's where the fun starts.

Our cutoff time is 11am. But because we "celebrate" Daylight Saving Time, 11am changes as the year goes on, so I couldn't just run the script at UTC - EST. No, I have to run the script twice, at UTC - EST and UTC - EDT. That means I have to add extra logic to determine what the correct local time is, so that we get the right content. Then, I have to update the cron job to run twice.

Quick, can you tell me what 11am EST is in UTC? And 11am EDT in UTC? I couldn't. I spent 15 minutes going back and forth with Time Zone Converter making sure I was setting the right UTC time for this script to run.

I'm an experienced programmer. I've wrangled dates before. They're one of the more complicated "simple" things in programming I've encountered. Network stack? Hah, childs play. Event loops? Easy peasy. Times and dates, with timezones? Let's just say I thank $DEITY every day that Sullivan Beck wrote the amazing Date::Manip module. I'd have pulled out my hair trying to deal with all it's complexity.

So, back to the title of this post. Daylight Saving should be abolished. Really, I think all timezones should be abolished, and everyone around the world should work on UTC time, but I know that's a bigger battle than needs fought. So, let's get rid of Daylight Saving. Only about 70 countries follow daylight savings, with many sections of countries no longer observing. Many studies have found no significant economic value in it; health concerns are mixed.

Abolish Daylight Saving Time, and lets go on with life, unadjusted for season.