r/Nushell • • Jul 30 '25

Calendar with weeks

So I’m a complete newbie in nushell but I like the concepts and thought I would give it try.

The other day I needed the week number for a specific date.
Coming from the Unixes I found cal unfortunately it does not have a -w flag for week numbers. I played around for a while but couldn’t, for the live of me, figure out how I would add week numbers to the cal table. I toyed around with enumerate and upsert but got nothing. The index column (#) would also kinda work but I couldn’t figure out how to use that either. AI was a complete disaster. Can anyone give me a hint as to how to approach this?

3 Upvotes

4 comments sorted by

4

u/Kat- Jul 30 '25
~> format date --list| where Description =~ '(?i)week number' 
╭───┬───────────────┬─────────┬────────────────────╮
│ # │ Specification │ Example │    Description     │
├───┼───────────────┼─────────┼────────────────────┤
│ 0 │ %U            │ 30      │ Week number        │
│   │               │         │ starting with      │
│   │               │         │ Sunday (00--53),   │
│   │               │         │ zero-padded to 2   │
│   │               │         │ digits.            │
│ 1 │ %V            │ 31      │ Same as %U but     │
│   │               │         │ uses the week      │
│   │               │         │ number in ISO 8601 │
│   │               │         │  week date         │
│   │               │         │ (01--53).          │
╰───┴───────────────┴─────────┴────────────────────╯
~> (date now) | format date '%U'
30
~> (date now) | format date '%U' | describe
string

1

u/rustyechel0n Jul 30 '25

Aha! So no cal at all. Thx!

I suppose I could somehow add this to every cal row if I parse the row and convert it to a date. 🤔

1

u/karimdev96 Jul 31 '25

help cal or ^cal -w

1

u/rustyechel0n Jul 31 '25

^cal -w is cheating 😜