Jacksonville Developers User Group

Learn new things...write better code.
Welcome to Jacksonville Developers User Group Sign in | Join | Help
in
Home Blogs Forums

Jonathan Bates

Code Katas: Time Collection

The upcoming JAXDUG meeting is centered around code/thought exercises to solve business problems.  That meeting posting makes mention of the Supermarket Pricing exercise from the Code Kata site, as well as asking others to submit ideas for exercises.  I presented one for consideration, and I just received one from JAXDUG member and MS Speech Server MVP, Marshal Harrison.  Marshall's kata is as follows:

I would like to see a kata devoted to collecting time from users.

Too often the quick solution seems to be record everything using Universal Time or in the local time zone (i.e. EST for JAXDIG members).

However this solution overlooks the complexities involved when collecting time from remote users either via some web interface or via phone. For example let’s say you have an alert  scheduling service and a remote user schedules something for 8:00 AM his local time in San Francisco. If you are hosted in Jacksonville you don’t want to alert him at 8:00 AM system time of the application as that will be 5:00 AM local time for the user. Not what the user intended.

While it is acceptable to store things using UTC how does one respond to events in the local time of the user?

Some issues to consider:

  • What is the local time of the user – i.e. how do you determine the user’s time zone?
  • What about Daylight Saving Time – not every state uses DST.
  • What do you do when time zones don’t follow state lines. Florida has two time zones as do numerous other states.
  • How do you handle the transition from normal time to DST or vice versa?  For example when does 2:30 AM occur? Actually it occurs twice when you do the transition in the fall but doesn’t occur at all during the spring transition.
  • These are just some of the problems encountered when dealing with a distributed user base for applications that deal with times of events.

Published Monday, November 26, 2007 1:03 PM by jonathanbates
Filed Under:

Comments

 

Eugene Chuvyrov said:

I have a very simple solution to this Kata--don't use the time zone features unless you absolutely have to. Of course, this principle can be applied to any area of life or software development, but having first-hand exposure to the problem, it would be safe to say that many hours of development time were wasted at our shop to account for the shift in time zones and conversion to and from GMT. We are using a SimpleTimeZone .Net class, which I believe was ported from the Java framework to transfer time to/from GMT. Since the users of our application are distributed across the nation, each user has a time zone value stored together with his/her name and credentials. The time is stored in the database as GMT (the only "true" time so to speak), and this time is converted to user's local time in all of the reports available to the user. The publicly facing portion of the web site (the one that doesn't require the users to log in) could be set to default to EST or GMT, but, fortunately, we didn't have to implement that for our solution. Now, for the painful part: when a data warehousing/dashboard solution was implemented based on the data in our OLTP database, the time zones were not taken into account, resulting in certain sales data to be skewed (monthly sales are incorrect, for example). There are also issues of users not setting the correct time zone for themselves, as well as "traveling" users who may end up in a time zone that is different from their preset one. In addition, the times that appear different for users in different time zones may raise questions from people not understanding what's going on, and trigger unnecessary support requests. So, don't do it unless you have to, or someone please shed some light on how to solve this better! This Karate Kid could use another lesson on time zone handling.
November 28, 2007 6:50 PM
Anonymous comments are disabled

About Jonathan Bates

Jonathan Bates is the latest President of the Jacksonville Developers User Group.

He has had a long and storied path on the way to I.T. work. At one point, Jonathan had a near Neo-Luddite position about computers, believing them at worst to be the means to humanity's eventual slavery and at best tools for general evil. After landing a job powered by such advanced technologies as Windows 3.11 for Workgroups and MS Access, Jonathan began to change his opinion on computers. He began to believe that they might be for more than just improving the display and sound qualities on his Laserdisc movies. In time, he came to see that computers were nothing more than tools, not much different then a hammer (though not as good to drive nails with).

Jonathan Bates is an industry-certified and proven developer and trainer, facilitating the transfer of knowledge from conceptual client request to delivered and implemented solution. Jonathan enjoys sharing his knowledge and understanding about development principals with like-minded people. You can generally find him enjoying good company discussing his personal Unified Theory and how programming can be used to describe it. And if you can't find him, drop him a line with a time and place and he'll find you.

Contact him at jonathan.bates@batener.org.

This Blog

Post Calendar

<November 2007>
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

News

Where to find me

  • Tuesdays after 6:30 PM
    Renna's
    Baymeadows and Baymeadows Way
  • Thursdays after 6:30 PM
    Panera's
    Baymeadows and Southside
  • Saturdays @ 10:30 AM
    Panera's
    Blanding and I-295

Syndication

Powered by Community Server, by Telligent Systems