A simplified way to show a calendar month in any console.
The exported module is a function that accepts an object with the following properties:
date
: the mandatory date object to use in order to display the monthstartDay
: the optional day of the week to use as starting day, by default it's1
(Monday)freeDay
: one or more optional days of the week to consider free, by default[0, 6]
(Sunday, Saturday)locale
: the optional locale to use, by defaulten
table
: an optional boolean value to indicate the layout should be a proper table, by default it'sfalse
year
: an optional boolean value to indicate if the month name should be followed the date year, by default it'sfalse
highlight
: an optional day of the month, eventually as list, to highlight. By default it's the current date.blink
: an optional day of the month, eventually as list, to show blinking, where possible. By default it's an empty listbold
: an optional day of the month, eventually as list, to show as bold, where possible. By default it's an empty listdim
: an optional day of the month, eventually as list, to show dimmed, where possible. By default it's an empty listunderline
: an optional day of the month, eventually as list, to show underlined, where possible. By default it's an empty list
The date.getDay()
method returns 0
for Sunday, 1
for Monday, and all other days 'till 6
for Saturday.
Both startDay
and freeDay
use this numeric convention for days of the week, but every other property uses the actual day of the month, which is never 0
or greater than 31
.
You can also pass just dates objects for every other field that is not startDay
or freeDay
, the function will convert those automatically.
// import monthly from 'monthly';
// or ...
var monthly = require('monthly');
var rows = monthly({
date: new Date,
startDay: 1,
freeDay: [0, 6],
locale: 'en',
highlight: [3, 9, 11, 20],
blink: 9,
bold: 10,
dim: 28,
underline: 12,
table: false,
year: false
});
console.log(rows.join('\n'));
Please note the function returns an array, so that it's possible to stack more months per row as shown via npm test
.
Usage: monthly [options]
Options:
--holidays <cc> dim holidays for the ISO 3166 country. (example: de gb it us)
-m, --month <mm> display a calendar for the month. (default: 8)
-y, --year [yyyy] display a calendar for the whole year. (default: 2018)
-s, --sunday display Sunday as the first day of the week.
-3, --three display three months spanning the date.
-v, --version output the version number
-h, --help output usage information
Please note the ISO 3166 country must be available in this repository.
If not available, --holidays
won't have any meaning so please file PRs if you'd like your country vacations listed in here, thanks.