قالب:Extract/doc
هذه صفحة توثيق فرعية لـ قالب:Extract. تتضمن معلومات الاستعمال، التصنيفات وأي محتوى آخر ليس من محتويات الأصل لصفحة القالب. |
Uses Lua: |
This template can extract information from a date, or can format a date. Time units can be added to a date.
Syntax
{{extract|date|options}}
The following options are available:
add=periods to add
• Add/subtract time units.fix=on
• Adjust invalid time units.partial=on
• Accept a year only, or a year and month only.show=what to display
• Specifies what should be extracted (such asdayname
), or how to format the date (such asmdy
).sortable=on
• A hidden sort key is inserted before the date (for use in sortable tables).
The date can be entered as the first parameter, or separate parameters can be used for the year/month/day/hour/minute/second components of a date.
By default, the date is displayed in dmy format, for example:
{{extract|2015-11-12}}
→ 12 نوفمبر 2015
Date
A valid date must be specified. Dates are UTC—local times and time zones are not supported.
Dates from 9999 BCE to 9999 CE are accepted. The proleptic Gregorian calendar is used by default. Entering the parameter julian
with a date uses the proleptic Julian calendar.
A date can include an era or a time, and a variety of formats are accepted.
Examples of valid dates follow. Each row shows two equivalent methods of entering a date.
A date as a single parameter | Components of a date in separate parameters |
---|---|
{{extract|1900-02-01}} |
{{extract|1900|02|01}}
|
{{extract|1900-2-1 14:45}} |
{{extract|1900|2|1|14|45}}
|
{{extract|1 FEB 1900}} |
{{extract|1900|FEB|1}}
|
{{extract|February 1, 1900}} |
{{extract|1900|February|1}}
|
{{extract|Feb 1 1900 14:45}} |
{{extract|1900|Feb|1|14|45}}
|
{{extract|2:45 pm February 1 1900}} |
{{extract|1900|February|1|14|45}}
|
{{extract|1 February 1900 2:45 p.m.}} |
{{extract|1900|February|1|14|45}}
|
{{extract|BC 1 Feb 120}} |
{{extract|-119|2|1}}
|
The last example above uses the rule:
- n BC is year 1 − n
Year 0 refers to 1 BC, and year −1 is 2 BC, etc.
Dates can also be entered with the following special names which are not case sensitive.
{{extract|juliandate|2451545}}
→ 1 يناير 2000 (Julian day 2451545 is noon 1 January 2000 UTC in the Gregorian calendar){{extract|juliandate|julian|2451545}}
→ 19 ديسمبر 1999 (which is 19 December 1999 in the Julian calendar){{extract|currentdate}}
→ 18 ديسمبر 2024 (the date shown is when this documentation page was last purged){{extract|currentdatetime}}
→ 18:48 18 ديسمبر 2024
The following confirms that 16 February 2000 in the Julian calendar was 29 February 2000 in the Gregorian calendar.
{{extract|julian|Feb 16, 2000|show=juliandate}}
→ 2451604 (Julian calendar was specified){{extract|juliandate|2451604}}
→ 29 فبراير 2000 (Gregorian calendar by default)
16 February 2000 in the Julian calendar can be converted to the Gregorian calendar in one line:
{{extract|juliandate|{{extract|julian|16 Feb 2000|show=juliandate}}}}
→ 29 فبراير 2000
Add
These time units can be added to a date:
y
yearsm
monthsd
daysh
hoursmin
minutess
seconds
Multiple periods can be given, separated by spaces. There must be no space between a value and the code for the time unit.
A hyphen can be used for a negative value. Periods are added in the order given.
Examples:
{{extract|2004-04-03|add=28d}}
→ 1 مايو 2004{{extract|2004-04-03|add=3m 28d}}
→ 31 يوليو 2004{{extract|2004-04-03|add=28d 3m}}
→ 1 أغسطس 2004 (the order in which units are added changes the result){{extract|2004-04-03|add=-3d}}
→ 31 مارس 2004{{extract|2004-04-03|add=-912345d}}
→ 5 مايو 495 BC{{extract|2004-04-03|add=250h}}
→ 10:00 13 أبريل 2004{{extract|2004-04-03|add=-2.5h}}
→ 21:30 2 أبريل 2004{{extract|2004-04-30|add=-2m}}
→ 29 فبراير 2004{{extract|2004-04-03|add=2y 3m 4d}}
→ 7 يوليو 2006{{extract|2004-04-03|add=5.75d}}
→ 18:00 8 أبريل 2004 (years and months are integer only)
Fix
By default, the date entered must be valid. If fix=on
is used, units which are too large are "fixed". For example, 26 hours would be regarded as 1 day and 2 hours.
Entering a day as zero is regarded as the previous day (the last day of the previous month). The day before the previous day would be indicated with -1
.
Similarly, entering a month as zero goes back one month, and entering -1
goes back two months.
Examples:
{{extract|2001|5|31|fix=on}}
→ 31 مايو 2001 (no fix is required){{extract|2001|5|0|fix=on}}
→ 30 أبريل 2001{{extract|2001|5|-1|fix=on}}
→ 29 أبريل 2001{{extract|2001|125|-1000|fix=on}}
→ 3 أغسطس 2008{{extract|2001|0|12|fix=on}}
→ 12 ديسمبر 2000{{extract|2016|3|0|fix=on}}
→ 29 فبراير 2016
The following shows how to get the date for a given year and day-of-year. For example, June 30, 2001 is day 181 in the year 2001, as can be seen by adding 181 days to the date just before January 1, 2001.
{{extract|June 30, 2001|show=dayofyear}}
→ 181 (date to day-of-year){{extract|2001|1|0|fix=on|add=181d|show=mdy}}
→ يونيو 30, 2001 (day-of-year to date)
Partial
If partial=on
is used, the date may consist of a year only, or a year and month only. Addition is not supported for a partial date.
{{extract|2001|5|partial=on}}
→ مايو 2001{{extract|2016|partial=on|show=isleapyear}}
→ 1
Show
The following table lists most of the show parameters that can be used. Some of these work properly only with a full date.
Parameter | Description |
---|---|
show=hide |
display nothing; may be useful with sortable=on
|
show=year |
year |
show=month |
month (1 to 12) |
show=day |
day of month (1 to 31) |
show=hour |
hour (0 to 23) |
show=minute |
minute (0 to 59) |
show=second |
second (0 to 59) |
show=dayabbr |
abbreviated name of day of week |
show=dayname |
full name of day of week |
show=dayofweek |
day-of-week (0=Sunday to 6=Saturday) |
show=dayofweekiso |
day-of-week (1=Monday to 7=Sunday) |
show=dayofyear |
day-of-year (1 to 366) |
show=era |
an era code such as BC or BCE |
show=format |
code for the detected format of the input date (dmy, mdy, ymd, or error) |
show=gsd |
Gregorian serial date |
show=juliandate |
Julian day |
show=isleapyear |
1 if the date is in a leap year; 0 otherwise |
show=monthabbr |
abbreviated name of month |
show=monthdays |
number of days in the month of the date |
show=monthname |
full name of month |
show=dmy |
show date as "day month year" (default) |
show=mdy |
show date as "month day, year" |
show=ymd |
show date as "year-month-day" |
Examples:
{{extract|1 Feb 2001}}
→ 1 فبراير 2001{{extract|FEB 1 2001}}
→ 1 فبراير 2001{{extract|2001-2-1}}
→ 1 فبراير 2001{{extract|1 Feb 2001|show=format}}
→ dmy{{extract|FEB 1 2001|show=format}}
→ mdy{{extract|2001-2-1|show=format}}
→ ymd{{extract|2001-2-29|show=format}}
→ error{{extract|1 Feb 2001|show=mdy}}
→ فبراير 1, 2001{{extract|1 Feb 2001|show=ymd}}
→ 2001-02-01{{extract|June 30, 2001|show=dayname}}
→ الجمعة{{extract|June 30, 2001|show=dayofyear}}
→ 181{{extract|2001-2-1|show=monthname}}
→ فبراير{{extract|2001-2-1|show=a %{dayname} in %{monthname} }}
→ a الأربعاء in فبراير
Some show
options will not produce a useful result with a partial date, for example:
{{extract|2001|partial=on|show=juliandate}}
→ juliandate{{extract|2001|partial=on|show=monthname}}
→ monthname
Sortable
The sort options are:
Parameter | Description |
---|---|
prefix=text |
Insert the given text before the result but after any sort key. |
sortable=off |
No sort key (default). |
sortable=on |
Output a hidden sort key for use in sortable tables. |
sortable=table |
Insert a sort key using table syntax data-sort-value="value"| .
|
sortable=debug |
Same as sortable=on but the sort key is displayed for testing.
|
The sort key is calculated from the juliandate
value. For a partial date such as May 2016, the first day in the range is used (1 May 2016).
If wanted, show=hide
can be used so the date is not displayed.
The prefix
parameter allows the insertion of text that will not interfere with sorting. For example, {{extract|500 BC|prefix=c.|partial=on|sortable=on}}
outputs a hidden sort key followed by "c. 500 BC".
Examples:
{{extract|1 Jan 2001|sortable=on}}
→ 1 يناير 2001{{extract|1 Jan 2001|sortable=on|show=hide}}
→{{extract|2300 BCE|partial=on|sortable=debug}}
→ 7005881367500000000♠2300 BCE{{extract|1 Jan 2001|sortable=debug}}
→ 7006245191050000000♠1 يناير 2001{{extract|1 Jan 2001|sortable=debug|show=hide}}
→ 7006245191050000000♠{{extract|00:12 1 Jan 2001|sortable=debug|show=hide}}
→ 7006245191050833333♠