Internet Pet Peeve #1 - Timezones
Far too often, many public-facing website will display a date and "time" about something - without at least displaying a reference to a timezone. How useful is that?
I mainly develope business software applications, and not surprisingly I also find many non-public internal applications without reference to any specific timezone - for critical business data no-less.
This may be all well and fine for an organization that operates entirely within a single timezone, but as I discovered the hard way years ago, what do you do when your web-enabled working group spans multiple timezones, and an executive in New York has a scheduled conference call with someone in their Vancouver office for 10:00am Pacific Standard Time (PST)?
Do you force him to make the conversion mentally on the fly each time he (or she) looks at that entry in your application? I don't think so. (Just because they get paid more, doesn't mean they're smarter)
My strategy, as it has evolved, is to first of all store all datetime sensitive information in a database - converted to UTC (GMT) time. This can be accomplished easily using the T-SQL GETUTCDATE() or with C# using {DateTime}.ToUniversalTime();.
Then, when a user needs to read the datetime information, you convert it their local timezone for display purposes only. This can be done in T-SQL using DATEADD(hh, {TimezoneOffSet}, {DateTime}) or C# with {DateTime}.AddHours({TimezoneOffSet});.
So how do you get the {TimezoneOffSet}value (example: -6)? Ask the user! Or store it with their other profile information in the database. Following are some examples from my applications for timezone selection.
As an aside, what prompted my rant? The .NET Base Class Library Team is asking for feedback on Time Zone Scenarios. Woohoo!
Peeve Posted!



Comments