Template:Datetime/doc: Difference between revisions

From Eco - English Wiki
[unchecked revision][unchecked revision]
m (→‎Example: Add another example.)
(Improve documentation.)
Line 1: Line 1:
{{doc/start}}
{{doc/start}}
== Example ==
<templatedata>
* One value: {{Template Sandbox/Demian/Datetime|2022-01-02}} date.
{
* Two values: {{Template Sandbox/Demian/Datetime|2022-01-02|text}} more text.
"params": {
* No values: {{Template Sandbox/Demian/Datetime}} date.
"1": {
"label": "Datetime",
"description": "String with a date, time, or date and time.",
"example": "2022-12-31, 23:21:59, 2000-01-02T03:04:05.006",
"type": "string",
"required": true
},
"2": {
"label": "Display text",
"description": "Text to display instead of the date or time.",
"example": "last year, tomorrow, January 1st, in February",
"type": "string"
}
},
"description": "Add the \"time\" HTML element around a date, time, or date & time text for better search engine results and to help people using accessibility technologies.",
"paramOrder": [
"1",
"2"
],
"format": "inline"
}
</templatedata>
Please refer to the [https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time &lt;time&gt;: The (Date) Time element] on MDN Web Docs for the exact specification of the ''datetime'' string and more examples.
 
== Usage ==
* With date only: {{tlx|Template_Sandbox/Demian/Datetime|''datetime''}}
* With date and text: {{tlx|Template_Sandbox/Demian/Datetime|''datetime''|''display text''}}
 
== Examples ==
{| class="wikitable"
|+ Usage examples, including an invalid one.
|-
! Code !! Result
|-
| {{tlx|Template Sandbox/Demian/Datetime|2022-01-02}} || {{Template Sandbox/Demian/Datetime|2022-01-02}}
|-
| {{tlx|Template Sandbox/Demian/Datetime|2022-02-01|In February}} || {{Template Sandbox/Demian/Datetime|2022-02-01|On February 1st}}
|-
| {{tlx|Template Sandbox/Demian/Datetime|12:30|half past noon}} || {{Template Sandbox/Demian/Datetime|12:30|half past noon}}
|-
| {{tlx|Template Sandbox/Demian/Datetime|2022-01-01T00:00:01}} || {{Template Sandbox/Demian/Datetime|2022-01-01T00:00:01}}
|-
| {{tlx|Template Sandbox/Demian/Datetime}} || {{Template Sandbox/Demian/Datetime|}}
|}
{{doc/end}}
{{doc/end}}
<includeonly>[[Category:Formatting templates]]</includeonly>

Revision as of 14:52, 26 February 2022

Template:Doc/start

Add the "time" HTML element around a date, time, or date & time text for better search engine results and to help people using accessibility technologies.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Datetime1

String with a date, time, or date and time.

Example
2022-12-31, 23:21:59, 2000-01-02T03:04:05.006
Stringrequired
Display text2

Text to display instead of the date or time.

Example
last year, tomorrow, January 1st, in February
Stringoptional

Please refer to the <time>: The (Date) Time element on MDN Web Docs for the exact specification of the datetime string and more examples.

Usage

Examples

Usage examples, including an invalid one.
Code Result
{{Template Sandbox/Demian/Datetime|2022-01-02}}
{{Template Sandbox/Demian/Datetime|2022-02-01|In February}}
{{Template Sandbox/Demian/Datetime|12:30|half past noon}}
{{Template Sandbox/Demian/Datetime|2022-01-01T00:00:01}}
{{Template Sandbox/Demian/Datetime}} ERROR: No value given to datetime template!

Template:Doc/end