Esc

nth_weekday_of_month

procedureextensionsince 0.36.1Source
  • macOS: nth_weekday_of_month works on macOS
  • Linux: nth_weekday_of_month works on Linux
  • Windows: nth_weekday_of_month works on Windows
  • Wasm: nth_weekday_of_month works on Wasm

Finds occurrence 1..5 or -1..-5 from the end; missing occurrences fail.

Signature

nth_weekday_of_month :: (
    year: s64,
    month: s64,
    day: Weekday,
    nth: s64
) -> (Date, Time_Error)
Example↗
second_sunday, error := nth_weekday_of_month(2024, 3, .SUNDAY, 2);
assert(error.kind == .NONE && second_sunday.day == 10);
last_friday, _ := nth_weekday_of_month(2024, 3, .FRIDAY, -1);
assert(last_friday.day == 29);

See also