Difference between revisions of "Template:Date serial/doc"
Jump to navigation
Jump to search
Line 2: | Line 2: | ||
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --> | <!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --> | ||
This template returns the date serial in year for a date specified by month number and day of month. By default the year is considered non leap, but this may be overridden. | This template returns the date serial in year for a date specified by month number and day of month. By default the year is considered non leap, but this may be overridden. | ||
− | |||
− | |||
; Syntax<nowiki>:</nowiki> | ; Syntax<nowiki>:</nowiki> | ||
Line 11: | Line 9: | ||
* The ''year'' parameter is optional, if specified, the named ''leapyear'' parameter is ignored. | * The ''year'' parameter is optional, if specified, the named ''leapyear'' parameter is ignored. | ||
* The named ''leapyear'' parameter (optional, default value 0, unless ''year'' is specified) is non-zero to get the proper date serial on dates starting at March 1st on leap years. | * The named ''leapyear'' parameter (optional, default value 0, unless ''year'' is specified) is non-zero to get the proper date serial on dates starting at March 1st on leap years. | ||
+ | |||
+ | == Examples == | ||
+ | * <code><nowiki>{{date serial|{{CURRENTMONTH}}|{{CURRENTDAY}}|leapyear={{isLeapYear}}}}</nowiki></code> → {{date serial|{{CURRENTMONTH}}|{{CURRENTDAY}}|leapyear={{isLeapYear}}}} | ||
+ | * <code><nowiki>{{date serial|1|1}}</nowiki></code> → {{date serial|1|1}} | ||
+ | * <code><nowiki>{{date serial|1|1|2000}}</nowiki></code> → {{date serial|1|1|2000}} | ||
+ | * <code><nowiki>{{date serial|1|1|leapyear=1}}</nowiki></code> → {{date serial|1|1|leapyear=1}} | ||
+ | * <code><nowiki>{{date serial|2|28}}</nowiki></code> → {{date serial|2|28}} | ||
+ | * <code><nowiki>{{date serial|3|1}}</nowiki></code> → {{date serial|3|1}} | ||
+ | * <code><nowiki>{{date serial|3|1|leapyear=0}}</nowiki></code> → {{date serial|3|1|leapyear=0}} | ||
+ | * <code><nowiki>{{date serial|3|1|1999}}</nowiki></code> → {{date serial|3|1|1999}} | ||
+ | * <code><nowiki>{{date serial|3|1|leapyear=1}}</nowiki></code> → {{date serial|3|1|leapyear=1}} | ||
+ | * <code><nowiki>{{date serial|3|1|2000}}</nowiki></code> → {{date serial|3|1|2000}} | ||
+ | * <code><nowiki>{{date serial|3|26}}</nowiki></code> → {{date serial|3|26}} | ||
+ | * <code><nowiki>{{date serial|5|1}}</nowiki></code> → {{date serial|5|1}} | ||
+ | * <code><nowiki>{{date serial|12|31}}</nowiki></code> → {{date serial|12|31}} | ||
+ | * <code><nowiki>{{date serial|12|31|leapyear=1}}</nowiki></code> → {{date serial|12|31|leapyear=1}} | ||
+ | * <code><nowiki>{{date serial|12|31|1999}}</nowiki></code> → {{date serial|12|31|1999}} | ||
+ | * <code><nowiki>{{date serial|12|31|2000}}</nowiki></code> → {{date serial|12|31|2000}} | ||
+ | |||
+ | Days since September 1st: | ||
+ | * <code><nowiki>{{#expr: {{date serial|{{CURRENTMONTH}}|{{CURRENTDAY}}}} - {{date serial|9|1}} }}</nowiki></code> → {{#expr: {{date serial|{{CURRENTMONTH}}|{{CURRENTDAY}}}} - {{date serial|9|1}} }} | ||
+ | |||
+ | First Sunday in November is November {{Weekday in month|{{CURRENTYEAR}}|11|0|1}}, {{CURRENTYEAR}} | ||
+ | * <code><nowiki>{{date serial|11|{{Weekday in month|{{CURRENTYEAR}}|11|0|1}} }}</nowiki></code> → {{date serial|11|{{Weekday in month|{{CURRENTYEAR}}|11|0|1}} }} | ||
+ | |||
+ | ==Self test== | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Test !! Result | ||
+ | |- | ||
+ | | <code><nowiki>{{date serial|1|13}}</nowiki></code> || {{#ifeq:{{date serial|1|13}}|13|Pass|Fail}} | ||
+ | |- | ||
+ | | <code><nowiki>{{date serial|2|12}}</nowiki></code> || {{#ifeq:{{date serial|2|12}}|43|Pass|Fail}} | ||
+ | |- | ||
+ | | <code><nowiki>{{date serial|3|16}}</nowiki></code> || {{#ifeq:{{date serial|3|16}}|75|Pass|Fail}} | ||
+ | |- | ||
+ | | <code><nowiki>{{date serial|4|1}}</nowiki></code> || {{#ifeq:{{date serial|4|1}}|91|Pass|Fail}} | ||
+ | |- | ||
+ | | <code><nowiki>{{date serial|4|2|leapyear=1}}</nowiki></code> || {{#ifeq:{{date serial|4|1|leapyear=1}}|92|Pass|Fail}} | ||
+ | |} | ||
==See also== | ==See also== |
Revision as of 16:32, 1 July 2011
![]() | This is a documentation subpage for Template:Date serial. It contains usage information, categories and other content that is not part of the original template page. |
This template returns the date serial in year for a date specified by month number and day of month. By default the year is considered non leap, but this may be overridden.
- Syntax:
- {{Date serial|month number|day of month}}
- {{Date serial|month number|day of month|year}}
- {{Date serial|month number|day of month|leapyear=is leap}}
- The year parameter is optional, if specified, the named leapyear parameter is ignored.
- The named leapyear parameter (optional, default value 0, unless year is specified) is non-zero to get the proper date serial on dates starting at March 1st on leap years.
Examples
{{date serial|{{CURRENTMONTH}}|{{CURRENTDAY}}|leapyear={{isLeapYear}}}}
→ 180{{date serial|1|1}}
→ 1{{date serial|1|1|2000}}
→ 1{{date serial|1|1|leapyear=1}}
→ 1{{date serial|2|28}}
→ 59{{date serial|3|1}}
→ 60{{date serial|3|1|leapyear=0}}
→ 60{{date serial|3|1|1999}}
→ 60{{date serial|3|1|leapyear=1}}
→ 61{{date serial|3|1|2000}}
→ 61{{date serial|3|26}}
→ 85{{date serial|5|1}}
→ 121{{date serial|12|31}}
→ 365{{date serial|12|31|leapyear=1}}
→ 366{{date serial|12|31|1999}}
→ 365{{date serial|12|31|2000}}
→ 366
Days since September 1st:
{{#expr: {{date serial|{{CURRENTMONTH}}|{{CURRENTDAY}}}} - {{date serial|9|1}} }}
→ -64
First Sunday in November is November Template:Weekday in month, 2025
{{date serial|11|{{Weekday in month|{{CURRENTYEAR}}|11|0|1}} }}
→ Expression error: Unexpected < operator.
Self test
Test | Result |
---|---|
{{date serial|1|13}} |
Pass |
{{date serial|2|12}} |
Pass |
{{date serial|3|16}} |
Pass |
{{date serial|4|1}} |
Pass |
{{date serial|4|2|leapyear=1}} |
Pass |
See also
- {{Gregorian serial date}} for the number of days since 0 A.D accounting for leap years.
- {{Age in days}} for the number of days between any two dates.