Jump to content

Template:Weekday in month/doc: Difference between revisions

From NicheWork
w>Peterwhy
m Usage: Replace the broken description lists (MOS:BADINDENT) and layout table of fixed width (MOS:LTAB)
 
m 1 revision imported
 
(No difference)

Latest revision as of 13:41, 19 January 2026

Usage

Code

Note that the order of the input can be reversed. The following give the same output.

  • {{Weekday in month|y|m|w|n}}
  • {{Weekday in month|n|w|m|y}}

Note that the year is optional. The following give the nth w-day of month m this year.

  • {{Weekday in month||m|w|n}}
  • {{Weekday in month|n|w|m}}

Parameters

y year numeric format, certain words, blank
  • Integers from 1000 to 9999 are accepted.
  • last year and next year are accepted.
  • The year is optional (defaults to the current year).
m month numeric format, spelt out in full or abbreviated
  • For numeric input a leading zero is optional.
  • Three-letter abbreviations are accepted (e.g. Jan, Feb, etc.)
w weekday spelt out in full or abbreviated (preferred)
  • Three-letter abbreviations are accepted (e.g. Sun, Mon, etc.)

or numeric format (discouraged)

  • The weekday numbering follows non-ISO practice (Sunday → 0, Monday → 1, ... Saturday → 6).
n count numeric format, spelt out in full or abbreviated
  • Positive integers give the nth Sunday/Monday ... Saturday of the month.
  • Negative integers give the nth last Sunday/Monday ... Saturday of the month.
  • Words are accepted (e.g. first, last, etc.)
  • Abbreviations are accepted (e.g. 1st, 2nd, etc.)

Examples

  • for the first Sunday of January 2000
    • n = first, 1st or 1
    • w = Sunday or Sun (or 0)
    • m = January, Jan or 1
    • y = 2000
  • for the first Monday of February 2006
    • n = first, 1st or 1
    • w = Monday or Mon (or 1)
    • m = February, Feb or 2
    • y = 2006
  • for the first Tuesday of March 2010
    • n = first, 1st or 1
    • w = Tuesday or Tue (or 2)
    • m = March, Mar or 3
    • y = 2010
  • for the second Tuesday of April 2012
    • n = second, 2nd or 2
    • w = Tuesdayor Tue (or 2)
    • m = April, Apr or 4
    • y = 2012
  • for the second Tuesday of May 2020
    • n = second, 2nd or 2
    • w = Tuesday or Tue (or 2)
    • m = May or 5
    • y = 2020
  • for the second Wednesday of June 2100
    • n = second, 2nd or 2
    • w = Wednesday or Wed (or 3)
    • m = June, Jun or 6
    • y = 2100
  • for the third Wednesday of July this year
    • n = third, 3rd or 3
    • w = Wednesday or Wed (or 3)
    • m = July, Jul or 7
    • y = {{#time:Y}}, {{CURRENTYEAR}} or leave it blank
  • for the third Thursday of August this year
    • n = third, 3rd or 3
    • w = Thursday or Thu (or 4)
    • m = August, Aug or 8
    • y = {{#time:Y}}, {{CURRENTYEAR}} or leave it blank
  • for the last Thursday of September last year
    • n = last or -1
    • w = Thursday or Thu (or 4)
    • m = September, Sep or 9
    • y = {{#time:Y|last year}}, {{LASTYEAR}} or last year
  • for the last Friday of October last year
    • n = last or -1
    • w = Friday or Fri (or 5)
    • m = October, Oct or 10
    • y = {{#time:Y|last year}}, {{LASTYEAR}} or last year
  • for the second last Friday of November next year
    • n = second last, 2nd last or -2
    • w = Friday or Fri (or 5)
    • m = November, Nov or 11
    • y = {{#time:Y|next year}}, {{NEXTYEAR}} or next year
  • for the second last Saturday of December next year
    • n = second last, 2nd last or -2
    • w = Saturday or Sat (or 6)
    • m = December, Dec or 12
    • y = {{#time:Y|next year}}, {{NEXTYEAR}} or next year

Calculation

The template then gives j, the day of the month, as calculated by the following formulae.

j = 7×n − 6 + (ww1) mod 7 (for positive n)
j = t + 7×(n + 1) − (wtw) mod 7 (for negative n)

Where t is the last day of the month, wt is the non-ISO weekday number of the last day of the month, w1 is the non-ISO weekday number of the first day of the month and n and w are as defined above.

Examples

year MLK Jr Day (US) Presidents Day (US) Memorial Day (US) Labor Day (US) Columbus Day (US) Father's Day
(Australia)
Mother's Day
(many countries)
Thanksgiving
(Norfolk Island)
Melbourne Cup Day
(Australia)
3rd Monday in January 3rd Monday in February Last Monday in May 1st Monday in September 2nd Monday in October 1st Sunday in September 2nd Sunday in May last Wednesday of November first Tuesday in November
2021 18 January 15 February 31 May 6 September 11 October 3 September 9 May 24 November 2 November
2021|1|1|3}}[note 1] 3|1|2|2021}}[note 1] 2021|5|1|-1}}[note 1] first|Monday|September|2021}} 2nd|Mon|Oct|2021}} 1st|sun|oct|2021}} 2|sun|may|2021}} last|Wed|Nov|2021}} 1st|Tue|Nov|2021}}
2022 17 January 21 February 30 May 5 September 10 October 2 September 8 May 30 November 1 November
2022|1|1|3}}[note 1] 3|1|2|2022}}[note 1] 2022|5|1|-1}}[note 1] first|Monday|September|2022}} 2nd|Mon|Oct|2022}} 1st|sun|oct|2022}} 2|sun|may|2022}} last|Wed|Nov|2022}} 1st|Tue|Nov|2022}}
2023 16 January 20 February 29 May 4 September 9 October 1 September 14 May 29 November 7 November
2023|1|1|3}}[note 1] 3|1|2|2023}}[note 1] 2023|5|1|-1}}[note 1] first|Monday|September|2023}} 2nd|Mon|Oct|2023}} 1st|sun|oct|2023}} 2|sun|may|2023}} last|Wed|Nov|2023}} 1st|Tue|Nov|2023}}
2024 15 January 19 February 27 May 2 September 14 October 6 September 12 May 27 November 5 November
2024|1|1|3}}[note 1] 3|1|2|2024}}[note 1] 2024|5|1|-1}}[note 1] first|Monday|September|2024}} 2nd|Mon|Oct|2024}} 1st|sun|oct|2024}} 2|sun|may|2024}} last|Wed|Nov|2024}} 1st|Tue|Nov|2024}}
2025
(last year)
20 January 17 February 26 May 1 September 13 October 5 September 11 May 26 November 4 November
2025|1|1|3}}[note 1] 3|1|2|2025}}[note 1] 2025|5|1|-1}}[note 1] first|Monday|September|2025}} 2nd|Mon|Oct|2025}} 1st|sun|oct|2025}} 2|sun|may|2025}} last|Wed|Nov|2025}} 1st|Tue|Nov|last year}}
2026
(this year)
19 January 16 February 25 May 7 September 12 October 4 September 10 May 25 November 3 November
2026|1|1|3}}[note 1] 3|1|2|2026}}[note 1] 2026|5|1|-1}}[note 1] first|Monday|September|2026}} 2nd|Mon|Oct|2026}} 1st|sun|oct|2026}} 2|sun|may|2026}} last|Wed|Nov|2026}} 1st|Tue|Nov}}
2027
(next year)
18 January 15 February 31 May 6 September 11 October 3 September 9 May 24 November 2 November
2027|1|1|3}}[note 1] 3|1|2|2027}}[note 1] 2027|5|1|-1}}[note 1] first|Monday|September|2027}} 2nd|Mon|Oct|2027}} 1st|sun|oct|2027}} 2|sun|may|2027}} last|Wed|Nov|2027}} 1st|Tue|Nov|next year}}

Notes

  1. 1.00 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20 But prefer Monday or Mon for w.

See also