Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Best Way to Represent Summer Time Rules?

I need to store the summer time (daylight saving time) change-over rules for different world regions in a database. I already have a way of storing regions and sub-regions (so the whole "half of Australia"/Arizona/Navaho problem is taken care of), but I'm wondering what the most efficient schema would be to accomplish this. The two options as I see them:

  • Have a table which contains unique one row for each year and region giving the start and end times for summer time as well as the specific offset
  • Have a table which stores a formula and effective date range for each region (effective range required for regions like Israel)

The advantage to the first is flexibility, since literally anything is possible. Unfortunately, it also requires (a) more space, and correspondingly (b) a lot of work to get the data input. The second is nice because one row could correspond to one region for decades, but it also requires some sort of language parser and interpreter in the application layer. Since this database will be used by several different applications written in languages without powerful text processing capabilities, I would rather avoid that route.

I would love to just use zoneinfo or something like that, but unfortunately that's not an option in this case. Likewise, I cannot normalize the dates, timezone and summer time info must be in the database to satisfy certain use cases.

Does anybody have any experience doing something similar? Likewise, does anyone have any brilliant options that I may have missed?

like image 789
Daniel Spiewak Avatar asked Sep 30 '08 18:09

Daniel Spiewak


People also ask

How do you indicate daylight savings time?

Clocks Back or Forward? “Spring forward, fall back” is one of the little sayings used to remember which way to set your watch. You set your clock forward one hour in the spring when DST starts (= lose 1 hour), and back one hour when DST ends in the fall (= regain 1 hour).

What does summer time represent?

Summer represents a time of our lives when we are strong and embarking on adventures. It symbolizes freedom, happiness, idleness and self-development. Positive times of friendship and love are often set in the summer months in books, poetry and film.

How does the summer time work?

Today, most Americans spring forward (turn clocks ahead and lose an hour) on the second Sunday in March (at 2:00 A.M.) and fall back (turn clocks back and gain an hour) on the first Sunday in November (at 2:00 A.M.).


1 Answers

You're pretty much doomed to the first option. You can pre-generate dates as far ahead as you wish for countries that have "rules" regarding time changes, but some areas do not have any rule and the changes are enacted either by dictatorial fiat or by legislative vote annually (Brazil did so until this year).

This is why all OS vendors roll out timezone file changes once or twice a year -- they have to, because they cannot generate a 100% accurate file programatically.

like image 126
Zathrus Avatar answered Sep 24 '22 22:09

Zathrus