Time Zones

Since the UNIX kernel bases its Epoch Time on the Greenwich Mean Time (GMT) time standard, it is instructive to do a review of time standards in general. Then, local time zones will be covered to provide a clear understanding of how they are related to the UNIX kernel clock.

Introducing World Time Standards

Originally, the GMT time standard was the world standard. Since then, a new world standard has emerged to coordinate the precise synchronization needed for distributed computer systems.

UNIX had its beginnings when GMT was the still the world standard. Consequently, much of the UNIX literature is steeped in the references to GMT today.

The GMT Time Standard

Greenwich Mean Time is based on the prime meridian of the Earth, which in 1884 was established as passing through Great Britain's Greenwich Observatory. Since then, the observatory has moved and been renamed the Royal Greenwich Observatory. However, its original location is still used to define the prime meridian.

The precise GMT time is determined by observations of the Sun. Due to variations in the Earth's rotation and its orbit around the Sun, small corrections are computed regularly and applied to arrive at the precise time.

The UTC Time Standard

UTC is the abbreviation for the time standard named Universelle Tempes Coordinaté in French, or Coordinated Universal Time in English. This standard is based on atomic clock measurements instead of solar observations, but it still uses the prime meridian. This standard replaced the GMT in 1986.

Choosing a World Time Standard

For many people, a fraction of a second is insignificant. They can set their UNIX system clocks according to the GMT time standard or the UTC time standard. The standards are so similar that they are sometimes used interchangeably.

The correct designation to use for the world time standard today is UTC. Consequently, new software should be written to display UTC instead of GMT.

Understanding Local Time Zones

UNIX allows for those people who do not live in the UTC time zone. This is done by taking your local time zone and adding an offset to arrive at UTC. In the Eastern time zone in North America, for example, UTC time is local time plus five hours. For much of Europe, it is the local time minus one hour.

Customizing Local Time Zones

Since UNIX is a multiuser operating system, it is designed to permit a user to define his own concept of local time. The tzset(3) function is used internally by a number of date and time functions to determine the local time zone. This function will be examined in more detail later in this chapter. The important thing to note is that it looks for an exported environment variable TZ to define your preference for local time. Your TZ value may be different from what other users on your system are using.

Setting the TZ Variable

When the environment variable TZ is found and has a properly defined value, the tzset(3) function will configure your local time zone. This will be used by the rest of the date and time functions where necessary. If the value TZ is not defined or is incorrectly set, the tzset(3) function falls back on the following zone information file (for FreeBSD):

/etc/localtime

Failing variable TZ and the zone information file, UTC time is assumed.

To configure your session for Eastern Standard Time and no daylight saving time, you can use

$ TZ=EST05
$ export TZ
							

This sets the time zone name to EST. Since it is west of the prime meridian, the offset is a positive 05 hours (think of this as local time + 5 hours = UTC). Eastern Daylight Saving Time can be configured as follows:

$ TZ=EST05EDT
$ export TZ
							

If you need more information on time zone configuration, a good place to start is the man(1) page for tzset(3). More advanced information is found in the tzfile(5) man pages.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.61.30