LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-31-2011, 03:24 PM   #1
hellolqs
LQ Newbie
 
Registered: Aug 2011
Posts: 16

Rep: Reputation: Disabled
Smile time zone offset definitions.


Hello,

I have a question about time zone offset in Linux.

Since Linux supports all different Time zones and DSTs, each of the time zone offset constants, for example EST/PST/CST/MST, should have been defined somewhere such as a header file or, other mechanisms may be used by Linux.

Could anyone help to provide some information?

Appreciated!!
 
Old 08-31-2011, 03:40 PM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
They're pretty much all found in /usr/share/zoneinfo, particularly the file /usr/share/zoneinfo/localtime (a symbolic link to /etc/localtime).

When you installed your distribution you were asked what time zone to use and that got set for you.

It's worth a look a the timezone manual page for more information.

Hope this helps some.
 
1 members found this post helpful.
Old 08-31-2011, 03:58 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
And
http://en.wikipedia.org/wiki/Tz_database
 
1 members found this post helpful.
Old 08-31-2011, 06:12 PM   #4
hellolqs
LQ Newbie
 
Registered: Aug 2011
Posts: 16

Original Poster
Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by tronayne View Post
They're pretty much all found in /usr/share/zoneinfo, particularly the file /usr/share/zoneinfo/localtime (a symbolic link to /etc/localtime).

When you installed your distribution you were asked what time zone to use and that got set for you.

It's worth a look a the timezone manual page for more information.

Hope this helps some.
Thank you! tronayne and Michael,

Sorry I did not mention that it is in an embedded environment and I realized that /usr/share/zoneinfo and /etc/localtime are actually not supported.

Just curious, could there be a header file which contains the constant definitions for time zone offsets?
Or, a Clib or system function that convert between the time zone offset value and a time zone name?

Thanks again.
 
Old 09-01-2011, 06:58 AM   #5
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
Perhaps you can do it the old-fashioned way by setting the TZ environment variable? You do not indicate where you are in the world but, for example, the eastern time zone in the United States is defined as
Code:
EST5EDT
where the EST is Eastern Standard Time, 5 is the difference to UTC during standard time, and EDT indicate that stupid... uh, daylight savings time is in use.

You can find an overview at http://en.wikipedia.org/wiki/Tz_database, and you can find the table of time zone information at http://en.wikipedia.org/wiki/List_of...ase_time_zones (if you had /usr/share/zoneinfo/zone.tab available, that's what the Wikipedia article is talking about).

Embedded system? I dunno if setting TZ will do any good (and, of course, you've got to have the proper offset and a way to figure out when or if daylight time goes into effect) or you just set your system clock to UTC and be done with it, eh?

Hope this helps some.
 
1 members found this post helpful.
Old 09-01-2011, 08:55 AM   #6
hellolqs
LQ Newbie
 
Registered: Aug 2011
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by tronayne View Post
Perhaps you can do it the old-fashioned way by setting the TZ environment variable? You do not indicate where you are in the world but, for example, the eastern time zone in the United States is defined as
Code:
EST5EDT
where the EST is Eastern Standard Time, 5 is the difference to UTC during standard time, and EDT indicate that stupid... uh, daylight savings time is in use.

You can find an overview at http://en.wikipedia.org/wiki/Tz_database, and you can find the table of time zone information at http://en.wikipedia.org/wiki/List_of...ase_time_zones (if you had /usr/share/zoneinfo/zone.tab available, that's what the Wikipedia article is talking about).

Embedded system? I dunno if setting TZ will do any good (and, of course, you've got to have the proper offset and a way to figure out when or if daylight time goes into effect) or you just set your system clock to UTC and be done with it, eh?

Hope this helps some.
Yes. It is very helpful. Thank you very much for the info.

 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
getting current time zone offset Skaperen Programming 1 06-19-2010 08:41 PM
Run script in EST time zone but server is in GMT zone jeesun Linux - Networking 1 04-04-2010 01:37 PM
how to get time offset from time zone venkat_k Programming 4 08-28-2009 08:29 AM
Thermal Zone Definitions for nx7400 efanning Linux - Laptop and Netbook 0 04-20-2007 01:09 PM
StepMania - Time offset ProfEich Linux - Games 0 10-01-2005 11:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:24 AM.

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