模板:Time
概要
此模板使用Lua语言: |
本模板显示由参数值指定的时区的现在时间,由该时区的UTC offset计算出来,如果该时区当时正在实施夏令时间,也会相应调整。
注意:为减轻服务器负荷,大多数条目页面显示该页面的缓存版本,所以该版本显示的“现在时间”可能已经过时。您可以点击[刷新]链接来更新现在时间。
参数
{{time}}
支持两个位置性及多个已命名参数。其中,无一为必要:
|<time zone>
– 首个位置性(未命名)参数,标明模板所出示之时区的时间。倘若未填,则出示UTC时间。维基百科中,时区由其标准时间之缩写识别。切勿使用夏令或日光节约时间之时区缩写,否则将被略过并出现错误。|<df>
– 位置性(未命名)的|df=
,请见|df=
– 日期格式;此参数可含多个值;除以下者,其他将被略过:|df=dmy
– 标明“日/月/年”格式;时间显示为二十四小时格式;别称:|df=dmy24
|df=dmy12
– 与|df=dmy
相同,惟时间为十二小时格式。|df=mdy
– 标明“月/日/,年”格式;时间显示为二十四小时格式;若日期格式未标明,此将被应用;别称:|df=mdy24
|df=mdy12
– 与|df=mdy
相同,惟时间显示为十二小时格式。|df=iso
– 以ISO 8601格式显示日期/时间(秒数不含于内)。|df=y
– 旧版{{time}}
参数,与|df=dmy
相同。|df=12
– 只显示十二小时格式的时间。|df=24
– 只显示二十四小时格式的时间。
|df-cust=
– 自定日期/时间格式,其使用于mw:Help:Extension:ParserFunctions##time界定之编码;取决[注 1]于|df=
。|df-cust-a=
– 如上,自定日期/时间格式,特别为上午(AM)时间;须|df-cust-p=
;取决于|df-cust=
。|df-cust-p=
– 如上,自定日期/时间格式,特别为下午(PM)时间;须|df-cust-a=
;取决于|df-cust=
。
|dst=
– 当被设为no
,该时区之日光节约时间计算将被停用;其他值会遭略过;不使用日光节约时间之地区宜用,如亚利桑那州。|lang=<code>
– 以ISO 639格式,用<code>
显示日期/时间。- 下列参数只可为
yes
:|dateonly=
– 压抑时间显示。|timeonly=
– 压抑日期显示。|hide-refresh=
– 压抑“刷新”按钮显示。|hide-tz=
– 压抑时区缩写显示。|unlink-tz=
– 显示非链接之时区缩写。
|_TEST_TIME_=
– 在此模板开发中卓有成效之参数。这的值须为以下其一:- 无时区代号之ISO 8601格式(2024-11-26T13:40:45)
- 以{{Timestamp}}(Template:Timestamp)产生之YYYYMMDDhhmmss格式。这会被视为UTC时间。
用法
Typically, all that is needed is:
To change the rendered format:
{{time|MST|df=y}}
{{time|MST|y}}
{{time|MST|dmy}}
{{time|MST|iso}}
支持的时区
This is a list of the currently supported time zone abbreviations:
- ACST (ACDT)
- AEST (AEDT)
- AKST (AKT)
- AoE[A]
- AST (AT) (ADT)
- AWST
- BST
- BT
- CET (CEST)
- ChST
- CST (CT) (CDT)
- EET (EEST)
- EST (ET) (EDT)
- GMT
- GMT-IE[B]
- GMT-UK[C]
- HAST (HADT) (HST) (HDT)
- IDLE[A]
- IDLW[A]
- IRKT
- IST
- JST
- KRAT
- MSK
- MST
- NST
- NZST (NZDT)
- OMST
- PETT
- PKT
- PMST[D]
- PST (PT) (PDT)
- SAMT
- SRET
- SST
- USZ1
- UTC
- VLAT
- WET (WEST)
- WGT[E]
- WIB
- WIT
- WITA
- YAKT
- YEKT
- ^ 1.0 1.1 1.2 Not standard time zones, these are included on a whim of the programmer; AoE is 'Anywhere on Earth', 'IDLE' and 'IDLW' are International Date Line East and West
- ^ Irish Standard Time. The abbreviation, IST, is also used for Indian Standard Time. Irish Standard Time occurs in the summer. For these reasons, the template uses GMT-IE as the time zone abbreviation for Ireland.
- ^ GMT does not observe daylight saving time. In the United Kingdom GMT is observed in winter but shifts to British Summer Time. The abbreviation BST is also used by Bangladesh Standard Time. To differentiate year-round GMT from GMT as observed in the UK, use GMT-UK.
- ^ Saint-Pierre and Miquelon Standard Time
- ^ Western Greenland Time
UTC offset
To display the time at a particular UTC offset, specify the UTC time offset as the time zone:
'UTC', a sign character, two hour digits, a colon, and two minute digits are required. Accepted sign characters are: '+', '-' (hyphen), '±', and '−' (minus).
Military/nautical time zones
To display the time at a particular military or nautical time zone,[1] use the time zone's alpha designation:
Some military and nautical time zone designators are extended with an asterisk (*), a dagger (†), or double dagger (‡). When writing this template for designators that are extended with a dagger or double dagger, use '+' and '++' respectively:
夏令时间
Daylight saving time (DST) calculations are automatic for those time zones where it is observed. 有些时区在实施夏令时间时,当中若干地区不跟随,在这些不使用夏令时间的地区可以使用|dst=no
:
{{time|MST|dst=no}}
- 2024年11月26日 06:40 MST [刷新] – time in Arizona
{{time|MST}}
- 2024年11月26日 06:40 MST [刷新] – but, time on the Navajo Nation in Arizona
The opposite case is not supported. For places like Thule Air Base in Greenland, which observes US DST rules while WGT observes EU DST rules, a time zone properties table will be needed in Module:Time. See §Adding a new time zone.
错误讯息
{{time}}
可以产生以下错误讯息,包括:
- {{time}} – both of |df-cust-a= and |df-cust-p required – when defining a custom format for am (or pm) time, you must also define a custom format for pm (or am) time
- {{time}} – error calculating dst timestamps – indicates an internal error because one or more of the following time zone properties is malformed: UTC offset, DST begin or end definition. To resolve this error make sure that the time zone's properties are correct.
- {{time}} – incomplete definition for ... – indicates an internal error because one or more of the following time zone properties is missing: DST begin or end definition, DST event time, time zone article. To resolve this error supply the missing properties.
- {{time}} – invalid date format <format> – value assigned to
|df=
is not one of the defined format strings; ss §Parameters - {{time}} – invalid use of ± - 符号±被用于the minute and hour offsets不是00:00的情形
- {{time}} – malformed or incomplete _TEST_TIME_ – value assigned to this parameter must either have the format: YYYY-MM-DDThh:mm:ss where all except 'T' are digits, or YYYYMMDDhhmmss
- {{time}} – unknown timezone – 填入的time zone positional parameter不是支持的时区缩写。To resolve this error check the parameter's spelling or add the time zone's properties to the module. 见§加入新时区。
加入新时区
{{time}}
使用Module:Time/data。这是一个有多个表格的表格,the data structure that specifies the properties of the individual time zones。空白的时区properties table有以下格式:
[''] = { abbr = '', dst_abbr = '', utc_offset = '', df = '', dst_begins = '', dst_ends = '', dst_time = '', dst_e_time = '', article = '' },
在Module:Time/data加入一个新时区,add the appropriate information inside the single quotes. If a property does not apply, leave the quotes empty. The rules for each property are:
['']
– (必填)一个时区标准时间的缩写,小写;this is the value that will be used in the template's time zone pararameterabbr = ''
– (必填)the abbreviation of a time zone's standard time as it will be rendered by the templatedst_abbr = ''
– 一个时区的夏令时间的缩写 as it will be rendered by the templateutc_offset = ''
– (必填)the offset in hours and minutes from UTC±00:00;采用以下格式:utc_offset = '<sign>hh:mm'
where<sign>
may be+
(optional) or-
(required for time zones west of the 0 meridian)df = ''
– one of three keywordsdmy
,mdy
, oriso
used to specify date format typically used in the time zone; can be overridden with|df=
template parameterdst_begins = ''
– a four word sentence in the form<ordinal>
<day name>
<in|of>
<month name>
where:<ordinal>
– 'first', '1st', 'second', '2nd', ... 'fifth', '5th', 或 'last'的其中一个<day name>
– 'Sunday', 'Monday', 'Tuesday', etc.的其中一个;capitalization is not important but otherwise must be spelled correctly;不支持缩写<in|of>
– 'in' 或 'of'的其中一个<month name>
– 月份名'January', 'February', 'March', etc.的其中一个;capitalization is not important but otherwise must be spelled correctly;不支持缩写
dst_ends = ''
– (required ifdst_begins
is specified) same asdst_begins
dst_time = ''
– (required ifdst_begins
is specified) the time that daylight saving time begins; usually local time; when DST begins at a specified time UTC (European Summer Time for example) use:dst_time = 'hh:mm UTC'
; four digits and the colon are requireddst_e_time = ''
– the time that daylight saving time ends if different from the time it begins; usually local daylight saving time ; when DST ends at a specified time UTC use:dst_e_time = 'hh:mm UTC'
; four digits and the colon are requiredarticle = ''
– (必填)该时区的条目名;do not include wikimarkup
The table-of-tables is organized east (plus UTC offsets) then west (minus UTC offset), by offset hours, and then alphabetically by time zone positional parameter name.
加入新alias
You may also want to add an alias of a timezone:
[''] = {tz = ''},
在Module:Time/data加入新时区,add the appropriate information inside the single quotes.
['']
– (required) the abbreviation of a time zone's alias. This must be lower case.tz = ''
– (required) the abbreviation of the time zone that's already in the code. This must be lower case
The table-of-tables is organized east (plus UTC offsets) then west (minus UTC offset), and by if it's a DST offset or if it's not.
See also
Template:Date and time templates
References
- ^ World Time Zone Map. HM Nautical Almanac Office. February 2016.
模板编辑说明
无描述。
参数 | 描述 | 类型 | 状态 | |
---|---|---|---|---|
time zone | 1 | The time zone for the time formatting
| 字符串 | 推荐 |
date format | 2 df | The format to render the date and time
| 未知 | 推荐 |
Daylight savings time | dst | 无描述
| 字符串 | 可选 |
ISO 639 language code | lang | displays time/date in language specified by ISO 639 language | 字符串 | 可选 |
dateonly | dateonly | If 'yes', suppresses display of the time and only shows the date
| 字符串 | 可选 |
timeonly | timeonly | If 'yes', suppresses display of the date and only shows the time
| 字符串 | 可选 |
Hide time zone? | hide-tz | If 'yes', suppresses time zone abbreviation
| 字符串 | 可选 |
Don't link time zone? | unlink-tz | If 'yes', renders the timezone without linking to its article.
| 字符串 | 可选 |
参见
引用错误:页面中存在<ref group="註">
标签,但没有找到相应的<references group="註" />
标签