I had a need to get the first Monday of each month of 2025.
- This can be changed to get any other first day by changing the wday variable.
- su, mo, tu, we, th, fr, sa
let wday = 'mo'
let year = 2025
cal -m -t --week-start $wday --full-year $year
| group-by month
| items {|mon cal|
let first_monday = ($cal
| where {|row| $row | get $wday | is-not-empty }
| first
| get $wday)
{
Monday: ($"($year)-($mon)-($first_monday)" | format date "%F")
}
}╭────┬────────────╮
│ # │ Monday │
├────┼────────────┤
│ 0 │ 2025-01-06 │
│ 1 │ 2025-02-03 │
│ 2 │ 2025-03-03 │
│ 3 │ 2025-04-07 │
│ 4 │ 2025-05-05 │
│ 5 │ 2025-06-02 │
│ 6 │ 2025-07-07 │
│ 7 │ 2025-08-04 │
│ 8 │ 2025-09-01 │
│ 9 │ 2025-10-06 │
│ 10 │ 2025-11-03 │
│ 11 │ 2025-12-01 │
├────┼────────────┤
│ # │ Monday │
╰────┴────────────╯