-   Linux - General (
-   -   Daylight Savings time (

depdiver 03-08-2006 12:13 PM

Daylight Savings time
How can I tell if the daylight savings flag is set? My state is observing daylight savings for the first time and I need to identify which Linux systems are and are not ready for it.


marozsas 03-08-2006 01:17 PM

The internal time on linux never changes, regardless your time zone settings.
The internal date/time can be presented to the user in a wide range of timezones. For instance,

miguel@gold:~> export TZ=Australia/Adelaide
miguel@gold:~> date
Thu Mar  9 05:34:43 CST 2006
miguel@gold:~> export TZ=Brazil/East
miguel@gold:~> date
Wed Mar  8 16:05:18 BRST 2006

There are several binary files on /usr/share/zoneinfo/ that tells to date command how to format the internal time and apply and corrections due the daylight savings rules for that time zone.

If none is fine for you, build your own. Read the zic(1) man page. It is the time zone compiler that will create a binary file zone info, from a text file you provide.

My text file for build a zone file for Brazil rules (which change every year btw) looks like this:

miguel@gold:~> cat /usr/local/etc/BrazilEast.zic
Rule    BR    2001  only  -    Oct  14 0:00  1:00  D
Rule    BR    2002  only  -    Feb  17 0:00  0:00  S
Rule    BR    2002  only  -    Nov  03 0:00  1:00  D
Rule    BR    2003  only  -    Feb  16 0:00  0:00  S
Rule    BR    2003  only  -    Oct  19 0:00  1:00  D
Rule    BR    2004  only  -    Feb  15 0:00  0:00  S
Rule    BR    2004  only  -    Nov  02 0:00  1:00  D
Rule    BR    2005  only  -    Feb  20 0:00  0:00  S
Rule    BR    2005  only  -    Oct  16 0:00  1:00  D
Rule    BR    2006  only  -    Feb  19 0:00  0:00  S

#Zone  NAME            GMTOFF  RULES/SAVE      FORMAT  [UNTIL]
Zone    Brazil/East      -3:00  BR            BR%sT

As you can see, last year the Brazil's daylight time started at Oct 16, and ends at Feb 19, this year.

When we are in Daylight saving time, the date command change the output to BRDT (where D stands for Daylight) and normal time is displayed as BRST (standard).

Just adapt my zic file for your needs, create the binary with the zic command. The resulting file will be placed by zic somewhere bellow /usr/share/zoneinfo/. The specific place is determined by the NAME field in the zic file, in my case, /usr/share/zoneinfo/Brazil/East.

After that, copy the binary file from /usr/share/zoneinfo to /etc/localtime and set somewhere in your system the default time zone (In SuSE is in /etc/sysconfig/clock).


Dragineez 03-08-2006 08:59 PM

Ah, so now we all know you're in Arizona. ;)

depdiver 03-09-2006 06:09 AM

Guess again... (Here's a hint: a famous 500 mile race happens on Memorial day weekend in my state)

prn 03-13-2006 01:30 PM

Did Arizona change to observing DST this year too?

I'm in the same state as depdiver, so I've had to do the same thing. The suggestion by marozsas should work fine, but under the circumstances is actually a lot more work than required. The easy way, which also allows a rather easy check to make sure it's correct is:


ln -sf /usr/share/zoneinfo/US/Eastern /etc/localtime
The nice part is that
ls -l /etc/localtime
will show by the link what zone you're observing. The "-sf" in the ln command will force the link, overwriting the original file.

I have to admit that I was not immediately positive that this would work with no other steps, so I lied to a test box and set the times to immediately before the spring and fall time changes and confirmed that the local time shown by, e.g., date changed as it was suppposed to.

One additional caveat is to watch out for cron jobs taking place between 1am and 3am. In the Spring, there will be no 2:00-3:00 am on the change day and in the fall, there will be TWO 1:00-2:00 hours so cron jobs in that range would run twice.

BTW, things will get more complicated in 2007 when the new start and end dates mandated by Congress take effect.

(ob quote -- Will Rogers: "If 'pro' is the opposite of 'con', what's the opposite of 'progress'?")

Good Luck,

All times are GMT -5. The time now is 04:04 PM.