Skip to content

DimitarVanguelov/TerminalCalendar.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TerminalCalendar

Build Status Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.

A simple package to view dates in monthly calendar format from the comfort of your REPL, built on top of PrettyTables.jl.

Currently, only the English language Gregorian calendar is supported.

Installation

This package is registered, thus it can be installed by running:

] add TerminalCalendar

Usage

There is only a single exported function calendar. In its most basic form, it takes zero arguments and prints the current month to the screen:

julia> calendar()

              November 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│   1234567 │
│   891011121314 │
│  15161718192021 │
│  22232425262728 │
│  2930 │     │     │     │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

or it can take two Int values for year and month:

julia> calendar(2021, 12)

              December 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │   12345 │
│   6789101112 │
│  13141516171819 │
│  20212223242526 │
│  2728293031 │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

You can also input a Date object (after importing Dates):

julia> calendar(Date(2021, 12))

              December 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │   12345 │
│   6789101112 │
│  13141516171819 │
│  20212223242526 │
│  2728293031 │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

The text table formats provided by PrettyTables.jl are re-exported so you could pass those as optional arguments to jazz up the how the calendar looks:

julia> calendar(2021, 12; tf=tf_compact)

              December 2021
 ----- ----- ----- ----- ----- ----- -----
  Mon   Tue   Wed   Thu   Fri   Sat   Sun
 ----- ----- ----- ----- ----- ----- -----
                1     2     3     4     5
    6     7     8     9    10    11    12
   13    14    15    16    17    18    19
   20    21    22    23    24    25    26
   27    28    29    30    31
 ----- ----- ----- ----- ----- ----- -----

Currently, only the text back-end formats are re-exported.

More options

You can pass in ranges:

julia> calendar(2021, 10:12)

               October 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │     │     │   123 │
│   45678910 │
│  11121314151617 │
│  18192021222324 │
│  25262728293031 │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

              November 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│   1234567 │
│   891011121314 │
│  15161718192021 │
│  22232425262728 │
│  2930 │     │     │     │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

              December 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │   12345 │
│   6789101112 │
│  13141516171819 │
│  20212223242526 │
│  2728293031 │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

You can also pass in vectors of dates:

julia> febs = lastdayofmonth.(Date(2010, 2):Year(1):Date(2020, 2));
julia> leap_febs = filter(x -> day(x) == 29, febs)
3-element Vector{Date}:
 2012-02-29
 2016-02-29
 2020-02-29

julia> calendar(leap_febs)

              February 2012
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │   12345 │
│   6789101112 │
│  13141516171819 │
│  20212223242526 │
│  272829 │     │     │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

              February 2016
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│   1234567 │
│   891011121314 │
│  15161718192021 │
│  22232425262728 │
│  29 │     │     │     │     │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

              February 2020
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │     │     │     │   12 │
│   3456789 │
│  10111213141516 │
│  17181920212223 │
│  242526272829 │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

You can get the calendar for a whole year simply by inputting a single Int:

julia> calendar(2021)

               January 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │     │     │   123 │
│   45678910 │
│  11121314151617 │
│  18192021222324 │
│  25262728293031 │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

              February 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│   1234567 │
│   891011121314 │
│  15161718192021 │
│  22232425262728 │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

                March 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│   1234567 │
│   891011121314 │
│  15161718192021 │
│  22232425262728 │
│  293031 │     │     │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

                April 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │     │   1234 │
│   567891011 │
│  12131415161718 │
│  19202122232425 │
│  2627282930 │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

                 May 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │     │     │     │   12 │
│   3456789 │
│  10111213141516 │
│  17181920212223 │
│  24252627282930 │
│  31 │     │     │     │     │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

                June 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │   123456 │
│   78910111213 │
│  14151617181920 │
│  21222324252627 │
│  282930 │     │     │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

                July 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │     │   1234 │
│   567891011 │
│  12131415161718 │
│  19202122232425 │
│  262728293031 │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

               August 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │     │     │     │     │   1 │
│   2345678 │
│   9101112131415 │
│  16171819202122 │
│  23242526272829 │
│  3031 │     │     │     │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

              September 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │   12345 │
│   6789101112 │
│  13141516171819 │
│  20212223242526 │
│  27282930 │     │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

               October 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │     │     │   123 │
│   45678910 │
│  11121314151617 │
│  18192021222324 │
│  25262728293031 │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

              November 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│   1234567 │
│   891011121314 │
│  15161718192021 │
│  22232425262728 │
│  2930 │     │     │     │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

              December 2021
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ Mon │ Tue │ Wed │ Thu │ Fri │ Sat │ Sun │
├─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │   12345 │
│   6789101112 │
│  13141516171819 │
│  20212223242526 │
│  2728293031 │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┘

Currently, displaying an entire year on one screen is not implemented, though that is a planned feature.

And there is more, just play around with it and see what works!


Development

Much thanks to Ronan Arraes Jardim Chagas for his help!

This package is mostly just fun and learning. If you have ideas for improvement, please open an issue, submit a PR, or contact me on Slack.

Planned Features

  • date highlighting
  • whole year calendar on one screen
  • ability to save a calendar table as a string