1753954 Members
7540 Online
108811 Solutions
New Discussion

Re: NTP Configuration

 
SOLVED
Go to solution
Johnson Punniyalingam
Honored Contributor
Solution

Re: NTP Configuration

Functions and Variables for Time Zones
â Variable: char * tzname [2]

The array tzname contains two strings, which are the standard names of the pair of time zones (standard and Daylight Saving) that the user has selected. tzname[0] is the name of the standard time zone (for example, "EST"), and tzname[1] is the name for the time zone when Daylight Saving Time is in use (for example, "EDT"). These correspond to the std and dst strings (respectively) from the TZ environment variable. If Daylight Saving Time is never used, tzname[1] is the empty string.

The tzname array is initialized from the TZ environment variable whenever tzset, ctime, strftime, mktime, or localtime is called. If multiple abbreviations have been used (e.g. "EWT" and "EDT" for U.S. Eastern War Time and Eastern Daylight Time), the array contains the most recent abbreviation.

The tzname array is required for POSIX.1 compatibility, but in GNU programs it is better to use the tm_zone member of the broken-down time structure, since tm_zone reports the correct abbreviation even when it is not the latest one.

Though the strings are declared as char * the user must refrain from modifying these strings. Modifying the strings will almost certainly lead to trouble.

â Function: void tzset (void)

The tzset function initializes the tzname variable from the value of the TZ environment variable. It is not usually necessary for your program to call this function, because it is called automatically when you use the other time conversion functions that depend on the time zone.

The following variables are defined for compatibility with System V Unix. Like tzname, these variables are set by calling tzset or the other time conversion functions.

â Variable: long int timezone

This contains the difference between UTC and the latest local standard time, in seconds west of UTC. For example, in the U.S. Eastern time zone, the value is 5*60*60. Unlike the tm_gmtoff member of the broken-down time structure, this value is not adjusted for daylight saving, and its sign is reversed. In GNU programs it is better to use tm_gmtoff, since it contains the correct offset even when it is not the latest one.

â Variable: int daylight

This variable has a nonzero value if Daylight Saving Time rules apply. A nonzero value does not necessarily mean that Daylight Saving Time is now in effect; it means only that Daylight Saving Time is sometimes in effect.


Thanks,
Johnson
Problems are common to all, but attitude makes the difference
Dennis Handly
Acclaimed Contributor

Re: NTP Configuration

>Could you please explain me more?

Unix and NTP work on UTC/GMT time, there are no timezones since it is universal.

Johnson has listed some of the Standard C functions that deal with timezones. These are built on top of UTC and the current time_t value. See ctime(3):
http://docs.hp.com/en/B2355-60130/ctime.3C.html

>Johnson: the array contains the most recent abbreviation.

The array contains what the user has set in TZ or /etc/TIMEZONE.
James R. Ferguson
Acclaimed Contributor

Re: NTP Configuration

Hi:

> because my some of the servers are running in diffrent time zone ie, UAE-4,UAE+4,GMT+4,WAT-4,SAST-2.

That's perfectly acceptable. As Dennis noted, UNIX and NTP operate in UTC (Coordinated Universal Time), otherwise called Greenwich Mean Time (GMT). UNIX begins time-keeping at its "Epoch" which is defined as Janyary 1, 1970 at 00:00:00 UTC. Time is tracked as the number of seconds since that Epoch.

A timezone is nothing more than a positive or negative offset from UTC. The time you perceive is your LOCAL view of time --- it is the real number of elpased seconds since the Epoch +- some number of (usually) whole hours. Timezones are purely political/social definitions.

As noted, it is the responsiblility of the libC library routines to compute what you see as your LOCAL time based on UTC time.

For your UAE+4 timezone, LOCAL time is +4 hours *behind* UTC whereas in your UAE-4 timezone the LOCAL time is -4 hours *ahead* of UTC. You can see this be setting the TZ variable on the command line _ONLY_ for the duration of a command. This is done thusly:

# TZ=UTC date
Sun Mar 1 20:39:47 UTC 2009
# TZ=UAE+4 date
Sun Mar 1 16:39:53 UAE 2009
# TZ=UAE-4 date
Mon Mar 2 00:39:57 UAE 2009

Thus, if you want, different users could have different timezones set in their login profiles and each would perceive time in their local timezones.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: NTP Configuration

>different time zone ie, UAE-4, UAE+4, GMT+4, WAT-4, SAST-2.

UAE+4 (unless in Brazil) isn't a valid TZ value, only UAE-4 is.

GMT can only have the suffix 0, GMT0. Otherwise the name will say GMT but will be 4 hours behind, something very confusing.

>JRF: TZ=UTC date

You should use "date -u" instead.
Actually I think this TZ is incorrect, you must use UTC0, otherwise you will follow US DST rules. Clay's dst.pl script should show this.
Dennis Handly
Acclaimed Contributor

Re: NTP Configuration

>ME: I think this TZ is incorrect, you must use UTC0, otherwise you will follow US DST rules.

Actually Clay's script shows it does work but the TZ documentation under environ(5) implies the offset isn't optional.
jeevarajkn
Frequent Advisor

Re: NTP Configuration

thanks to all Iam closing the thread....