LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-08-2006, 12:13 PM   #1
depdiver
Member
 
Registered: Aug 2004
Distribution: RedHat Enterprise, SLED 10, Freespire
Posts: 49

Rep: Reputation: 15
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.

Thanks,
 
Old 03-08-2006, 01:17 PM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
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,
Code:
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
miguel@gold:~>
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:
Code:
miguel@gold:~> cat /usr/local/etc/BrazilEast.zic
#Rule   NAME  FROM  TO    TYPE  IN   ON AT    SAVE  LETTER/S
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).

regards,
 
Old 03-08-2006, 08:59 PM   #3
Dragineez
Member
 
Registered: Oct 2005
Location: Annapolis
Distribution: Ubuntu
Posts: 278

Rep: Reputation: 41
Az

Ah, so now we all know you're in Arizona.
 
Old 03-09-2006, 06:09 AM   #4
depdiver
Member
 
Registered: Aug 2004
Distribution: RedHat Enterprise, SLED 10, Freespire
Posts: 49

Original Poster
Rep: Reputation: 15
Guess again... (Here's a hint: a famous 500 mile race happens on Memorial day weekend in my state)
 
Old 03-13-2006, 01:30 PM   #5
prn
Member
 
Registered: Apr 2005
Location: Muncie, IN, USA
Posts: 58

Rep: Reputation: 16
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:

Code:
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,
Paul
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Daylight savings time depdiver Red Hat 2 02-21-2006 10:00 AM
Daylight savings time Jeebizz Slackware 13 11-21-2005 08:08 PM
NTP and Daylight Savings Time jrdioko Linux - Software 8 11-01-2005 09:25 AM
Daylight Savings Time and Linux cereal83 Linux - General 6 10-31-2005 05:28 PM
Daylight savings time Problem bogus__13 Linux - General 1 04-04-2005 10:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration