模板:Time/doc
此頁面是Template: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-09T05:32:55)
- 以{{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月8日 22:32 MST [刷新] – time in Arizona
{{time|MST}}
- 2024年11月8日 22:32 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="註" />
標籤