nushell/docs/commands/cal.md
Joseph T. Lyons 353b33be1b
Add support to allow the week day start in cal to be configured via a flag (#1996)
* Add support to allow the week day start in cal to be configurable

* Fix variable name

* Use a flag instead of a configuration setting for specifying the starting day of the week
2020-06-19 05:34:51 +12:00

23 KiB

cal

Use cal to display a calendar.

Flags

  • -y, --year: Display the year column
  • -q, --quarter: Display the quarter column
  • -m, --month: Display the month column
  • --full-year <integer>: Display a year-long calendar for the specified year
  • --week-start <string>: Display the calendar with the specified day as the first day of the week
  • --month-names: Display the month names instead of integers

Examples

> cal
───┬────────┬────────┬─────────┬───────────┬──────────┬────────┬──────────
 # │ sunday │ monday │ tuesday │ wednesday │ thursday │ friday │ saturday
───┼────────┼────────┼─────────┼───────────┼──────────┼────────┼──────────
 0 │        │        │         │           │          │      12
 13456789
 210111213141516
 317181920212223
 424252627282930
 531 │        │         │           │          │        │
───┴────────┴────────┴─────────┴───────────┴──────────┴────────┴──────────
> cal -yqm --full-year 2020
────┬──────┬─────────┬───────┬────────┬────────┬─────────┬───────────┬──────────┬────────┬──────────
 #  │ year │ quarter │ month │ sunday │ monday │ tuesday │ wednesday │ thursday │ friday │ saturday
────┼──────┼─────────┼───────┼────────┼────────┼─────────┼───────────┼──────────┼────────┼──────────
  0202011 │        │        │         │         1234
  1202011567891011
  220201112131415161718
  320201119202122232425
  42020112627282930315202012 │        │        │         │           │          │        │        1
  62020122345678
  72020129101112131415
  820201216171819202122
  920201223242526272829
 102020131234567
 11202013891011121314
 1220201315161718192021
 1320201322232425262728
 14202013293031 │           │          │        │
 15202024 │        │        │         │         1234
 16202024567891011
 1720202412131415161718
 1820202419202122232425
 192020242627282930 │        │
 20202025 │        │        │         │           │          │      12
 212020253456789
 2220202510111213141516
 2320202517181920212223
 2420202524252627282930
 2520202531 │        │         │           │          │        │
 26202026 │        │      123456
 2720202678910111213
 2820202614151617181920
 2920202621222324252627
 30202026282930 │           │          │        │
 31202037 │        │        │         │         1234
 32202037567891011
 3320203712131415161718
 3420203719202122232425
 3520203726272829303136202038 │        │        │         │           │          │        │        1
 372020382345678
 382020389101112131415
 3920203816171819202122
 4020203823242526272829
 412020383031 │         │           │          │        │
 42202039 │        │        │       12345
 432020396789101112
 4420203913141516171819
 4520203920212223242526
 4620203927282930 │          │        │
 472020410 │        │        │         │           │        123
 48202041045678910
 49202041011121314151617
 50202041018192021222324
 51202041025262728293031
 5220204111234567
 532020411891011121314
 54202041115161718192021
 55202041122232425262728
 5620204112930 │         │           │          │        │
 572020412 │        │        │       12345
 5820204126789101112
 59202041213141516171819
 60202041220212223242526
 6120204122728293031 │        │
────┴──────┴─────────┴───────┴────────┴────────┴─────────┴───────────┴──────────┴────────┴──────────
> cal -yqm --full-year 2020 --month-names
────┬──────┬─────────┬───────────┬────────┬────────┬─────────┬───────────┬──────────┬────────┬──────────
 #  │ year │ quarter │ month     │ sunday │ monday │ tuesday │ wednesday │ thursday │ friday │ saturday
────┼──────┼─────────┼───────────┼────────┼────────┼─────────┼───────────┼──────────┼────────┼──────────
  020201 │ january   │        │        │         │         1234
  120201 │ january   │      567891011
  220201 │ january   │     12131415161718
  320201 │ january   │     19202122232425
  420201 │ january   │     262728293031520201 │ february  │        │        │         │           │          │        │        1
  620201 │ february  │      2345678
  720201 │ february  │      9101112131415
  820201 │ february  │     16171819202122
  920201 │ february  │     23242526272829
 1020201 │ march     │      1234567
 1120201 │ march     │      891011121314
 1220201 │ march     │     15161718192021
 1320201 │ march     │     22232425262728
 1420201 │ march     │     293031 │           │          │        │
 1520202 │ april     │        │        │         │         1234
 1620202 │ april     │      567891011
 1720202 │ april     │     12131415161718
 1820202 │ april     │     19202122232425
 1920202 │ april     │     2627282930 │        │
 2020202 │ may       │        │        │         │           │          │      12
 2120202 │ may       │      3456789
 2220202 │ may       │     10111213141516
 2320202 │ may       │     17181920212223
 2420202 │ may       │     24252627282930
 2520202 │ may       │     31 │        │         │           │          │        │
 2620202 │ june      │        │      123456
 2720202 │ june      │      78910111213
 2820202 │ june      │     14151617181920
 2920202 │ june      │     21222324252627
 3020202 │ june      │     282930 │           │          │        │
 3120203 │ july      │        │        │         │         1234
 3220203 │ july      │      567891011
 3320203 │ july      │     12131415161718
 3420203 │ july      │     19202122232425
 3520203 │ july      │     2627282930313620203 │ august    │        │        │         │           │          │        │        1
 3720203 │ august    │      2345678
 3820203 │ august    │      9101112131415
 3920203 │ august    │     16171819202122
 4020203 │ august    │     23242526272829
 4120203 │ august    │     3031 │         │           │          │        │
 4220203 │ september │        │        │       12345
 4320203 │ september │      6789101112
 4420203 │ september │     13141516171819
 4520203 │ september │     20212223242526
 4620203 │ september │     27282930 │          │        │
 4720204 │ october   │        │        │         │           │        123
 4820204 │ october   │      45678910
 4920204 │ october   │     11121314151617
 5020204 │ october   │     18192021222324
 5120204 │ october   │     25262728293031
 5220204 │ november  │      1234567
 5320204 │ november  │      891011121314
 5420204 │ november  │     15161718192021
 5520204 │ november  │     22232425262728
 5620204 │ november  │     2930 │         │           │          │        │
 5720204 │ december  │        │        │       12345
 5820204 │ december  │      6789101112
 5920204 │ december  │     13141516171819
 6020204 │ december  │     20212223242526
 6120204 │ december  │     2728293031 │        │
────┴──────┴─────────┴───────────┴────────┴────────┴─────────┴───────────┴──────────┴────────┴──────────
> cal -ym --full-year 2303 --month-names | where month == "june"
───┬──────┬───────┬────────┬────────┬─────────┬───────────┬──────────┬────────┬──────────
 # │ year │ month │ sunday │ monday │ tuesday │ wednesday │ thursday │ friday │ saturday
───┼──────┼───────┼────────┼────────┼─────────┼───────────┼──────────┼────────┼──────────
 02303 │ june  │        │      123456
 12303 │ june  │      78910111213
 22303 │ june  │     14151617181920
 32303 │ june  │     21222324252627
 42303 │ june  │     282930 │           │          │        │
───┴──────┴───────┴────────┴────────┴─────────┴───────────┴──────────┴────────┴──────────
> cal -my --full-year 2020 --month-names | default friday 0 | where friday == 13
───┬──────┬──────────┬────────┬────────┬─────────┬───────────┬──────────┬────────┬──────────
 # │ year │ month    │ sunday │ monday │ tuesday │ wednesday │ thursday │ friday │ saturday
───┼──────┼──────────┼────────┼────────┼─────────┼───────────┼──────────┼────────┼──────────
 02020 │ march    │      891011121314
 12020 │ november │      891011121314
───┴──────┴──────────┴────────┴────────┴─────────┴───────────┴──────────┴────────┴──────────
> cal -ymq --month-names --week-start-day monday
───┬──────┬─────────┬───────┬────────┬─────────┬───────────┬──────────┬────────┬──────────┬────────
 # │ year │ quarter │ month │ monday │ tuesday │ wednesday │ thursday │ friday │ saturday │ sunday
───┼──────┼─────────┼───────┼────────┼─────────┼───────────┼──────────┼────────┼──────────┼────────
 020202 │ june  │      1234567
 120202 │ june  │      891011121314
 220202 │ june  │     15161718192021
 320202 │ june  │     22232425262728
 420202 │ june  │     2930 │           │          │        │          │
───┴──────┴─────────┴───────┴────────┴─────────┴───────────┴──────────┴────────┴──────────┴────────