加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

POSIX1003.1 时区字符串格式

(2013-01-16 18:02:31)
标签:

it


时区字符串格式

示例:
[continent/city]
TZ=posix-tz-string
Time zones that do not have daylight savings have a simple TZ string, e.g.
[Pacific/Honolulu]
TZ=HST10
Where HST is the designation for the time zone (in this case Hawaii Standard Time) and 10 is the offset in hours. The offset indicates the value one must add to the local time to arrive at Coordinated Universal Time (UTC, aka GMT), and so it is positive for west of the meridian, e.g. America, and negative for east, e.g. China.
[Asia/Beijing]
TZ=CST-8
Minutes and seconds are optional, so CST-8 and CST-08:00:00 mean the same thing. Note that the sign convention (+/-) used in a Posix TZ string is the opposite to that used in Internet time offsets (RFC 3339) and in Arthur David Olson's TZ data files.

Let's examine the TZ string for a city with daylight saving time

[America/New_York]
TZ=EST5EDT,M3.2.0/2,M11.1.0
EST = designation for standard time when daylight saving is not in force 
5 = offset in hours = 5 hours west of Greenwich meridian (i.e. behind UTC) 
EDT = designation when daylight saving is in force (if omitted there is no daylight saving)
, = no offset number between code and comma, so default to one hour ahead for daylight saving 
M3.2.0 = when daylight saving starts = the 0th day (Sunday) in the second week of month 3 (March)
/2, = the local time when the switch occurs = 2 a.m. in this case 
M11.1.0 = when daylight saving ends = the 0th day (Sunday) in the first week of month 11 (November). No time is given here so the switch occurs at 02:00 local time.

So daylight saving starts on the second sunday in March and finishes on the first Sunday in November. The switch occurs at 02:00 local time in both cases. This is the default switch time, so the /2 isn't strictly needed.

[Europe/Paris]
TZ=CET-1CEST,M3.5.0/2,M10.5.0/3
CET = designation for standard time when daylight saving is not in force 
-1 = offset in hours = negative so 1 hour east of Greenwich meridian 
CEST = designation when daylight saving is in force ("Central European Summer Time")
, = no offset number between code and comma, so default to one hour ahead for daylight saving 
M3.5.0 = when daylight saving starts = the last Sunday in March (the "5th" week means the last in the month)
/2, = the local time when the switch occurs = 2 a.m. in this case 
M10.5.0 = when daylight saving ends = the last Sunday in October.
/3, = the local time when the switch occurs = 3 a.m. in this case 

The European Union time zones are arranged so the switch takes place at the same time in all zones.

[America/St_Johns]
TZ=NST03:30NDT,M3.2.0/0:01,M11.1.0/0:01
Newfoundland's standard time is three and a half hours behind UTC with daylight saving beginning on the second Sunday in March and ending on the first Sunday in November, but the switch occurs at one minute past midnight local time.

As an extreme example, consider the mythical city of Foobar in Atlantis.

[Atlantis/Foobar]
TZ=AST2:45ADT0:45,M4.1.6/1:45,M10.5.6/2:45
Atlantis Standard Time (AST) is 2 hours 45 minutes behind UTC and for daylight saving (ADT) they put their clocks forward two hours (i.e. to be 45 minutes behind UTC). Daylight saving starts on the first Saturday in April with the switch happening at 01:45 in the morning, and daylight saving ends on the last Saturday in October with the switch at 02:45 local time.

格式
=================================================================================

 TZ    Timezone information. TZ has the form:

                stdoffset[dst[offset],[start[/time],end[/time]]]

           std and dst
                 Three or more bytes that are the designation for
                 the  standard  (std)  and  daylight savings time
                 (dst) timezones.  Only std is required.  If  dst
                 is  missing, then daylight savings time does not
                 apply in  this  locale.  Upper-  and  lower-case
                 letters  are  allowed.   Any characters except a
                 leading colon (:), digits, a comma (,), a  minus
                 (-) or a plus (+) are allowed.

           offset
                 Indicates the value one must add  to  the  local
                 time  to  arrive  at Coordinated Universal Time.
                 The offset has the form:

                 hh[:mm[:ss]]

                 The minutes (mm) and seconds (ss) are  optional.
                 The  hour  (hh)  is required and may be a single
                 digit.  The offset following  std  is  required.
                 If no offset follows dst , daylight savings time
                 is assumed to be  one  hour  ahead  of  standard
                 time.  One or more digits may be used; the value
                 is always interpreted as a decimal number.   The
                 hour  must  be between 0 and 24, and the minutes
                 (and seconds) if present between 0 and 59.   Out
                 of   range   values   may   cause  unpredictable
                 behavior.  If preceded by a "-" the timezone  is
                 east of the Prime Meridian; otherwise it is west
                 (which may be indicated by an optional preceding
                 "+" sign).

           start/time,end/time
                 Indicate when to change to and  back  from  day-
                 light  savings  time, where start/time describes
                 when the change from standard time  to  daylight
                 savings time occurs, and end/time describes when
                 the  change  back  happens.   Each  time   field
                 describes  when,  in  current  local  time,  the
                 change is made.

                 The formats of start and end are one of the fol-
                 lowing:

                 Jn    The Julian day n (1 < n < 365). Leap  days
                       are  not  counted.  That is, in all years,
                       February 28 is day 59 and March 1  is  day
                       60.   It  is  impossible  to  refer to the
                       occasional February 29.

                 n     The zero-based Julian day (0 < n  <  365).
                       Leap  days are counted, and it is possible
                       to refer to February 29.

                 Mm.n.d
                       The d**th day, (0 < d < 6) of  week  n  of
                       month  m  of  the year (1 < n < 5, 1 < m <
                       12), where week 5 means "the last d-day in
                       month  m"  which  may  occur in either the
                       fourth or the fifth week). Week 1  is  the
                       first week in which the  d**th day occurs.
                       Day zero is Sunday.

           Implementation specific defaults are used  for   start
           and end if these optional fields are not given.

                 The time has the same format  as  offset  except
                 that no leading sign ("-" or "+" is allowed. The
                 default, if time is not given is 02:00:00.

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有