I Hate Daylight Savings Time!!!

I can’t think of anything that disrupts your life like the daylight savings time. First of all, it does NOT save energy. Not these days in age. It might have been beneficial during the times of Ben Franklin when the economy was based on agricultural output. I think we live in different age; people haven’t caught up to the time yet.

Anyways, it presents more problems for me as developer. Because DST is not universally accepted, I have to take DST into account when presenting the users with their local time. There’s a way to take educated guess using browser’s country setting. Then there’s a way to call it from client-side JavaScript using getTimeZoneOffset() method, but it has to be invoked by the client.

The solution? Have the users define it.

It sounds stupid, but this is probably the most accurate way to do it. Once you capture it, save it to the user’s information. However, be extremely careful not to store GMT + or - value. Yes, I have seen this. This is because cities like Phoenix, AZ and Tucson, AZ do not practice DST.

Once you have it, use tzinfo GEM. It’s extremely easy to use and best of all, it automatically adjusts to DST. All you have to do is pass the date/time stamp in UTC format and you’re good to go.

You can simply install it by sudo gem install tzinfo. Just make sure you install it on the server as even the tzinfo plugin requires it.

Comments

Leave a Reply

You must be logged in to post a comment.