Ref:
[1] http://www.gnu.org/software/libc/manual/html_node/Time-Zone-Functions.html
[0] Find the time zone table in your system
# cat /usr/share/zoneinfo/zone.tab
# <pre>
# @(#)zone.tab 8.38
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
#
# TZ zone descriptions
#
# From Paul Eggert (1996-08-05):
#
# This file contains a table with the following columns:
# 1. ISO 3166 2-character country code. See the file `iso3166.tab'.
# 2. Latitude and longitude of the zone's principal location
# in ISO 6709 sign-degrees-minutes-seconds format,
# either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS,
# first latitude (+ is north), then longitude (+ is east).
# 3. Zone name used in value of TZ environment variable.
# 4. Comments; present if and only if the country has multiple rows.
#
# Columns are separated by a single tab.
# The table is sorted first by country, then an order within the country that
# (1) makes some geographical sense, and
# (2) puts the most populous zones first, where that does not contradict (1).
#
# Lines beginning with `#' are comments.
#
#country-
#code coordinates TZ comments
AD +4230+00131 Europe/Andorra
AE +2518+05518 Asia/Dubai
AF +3431+06912 Asia/Kabul
AG +1703-06148 America/Antigua
AI +1812-06304 America/Anguilla
AL +4120+01950 Europe/Tirane
AM +4011+04430 Asia/Yerevan
AN +1211-06900 America/Curacao
AO -0848+01314 Africa/Luanda
AQ -7750+16636 Antarctica/McMurdo McMurdo Station, Ross Island
AQ -9000+00000 Antarctica/South_Pole Amundsen-Scott Station, South Pole
AQ -6734-06808 Antarctica/Rothera Rothera Station, Adelaide Island
AQ -6448-06406 Antarctica/Palmer Palmer Station, Anvers Island
AQ -6736+06253 Antarctica/Mawson Mawson Station, Holme Bay
AQ -6835+07758 Antarctica/Davis Davis Station, Vestfold Hills
:
:
What we are interested are TZ and comments :) We may show the comments in our UI timezone list for user to select his own timezone.
[1] To set your timezone
Method#1:
# export TZ=Asia/Taipei
To get timezone setting
# echo $TZ
Method#2:
If TZ is empty or not set, /etc/localtime is used.
So, we can use symbolic link as below to set timezone.
# ln -s /usr/shar/zoneinfo/Asia/Taipei /etc/localtime
or
# export TZ=/etc/localtime
/etc/localtime is a symbolic link to your timezone file.
[2] For C user:
...
some UI work to get the timezone to be set....
...
setenv("TZ", "Asia/Taipei", 1); /// "Asia/Taipei" is the timezone you may want to set
沒有留言:
張貼留言