Calendar.js
Calendar.js provide a fast way to work with dates when you don't wanna deal with hours, minute, second and so on. It means that Calendar.js comes in handy when you wanna work with something like a 'calendar based app' or maybe you need some locally date system for a browser game.The Class is really easy-to-use: once you had import the module, instantiate a calendar object, set a year range and you get a json with a ordered list containing all the days belonging to those years.
Import
You have a couple of way to import the package:
Copy the raw js
The simplest way is to grab the raw js from https://github.com/ActuallyNotaDev/Calendar.js/blob/main/calendar.js, make a new js file, paste it. after that from your entry script:
import calendar from '<PATH>/calendar.js';
var ๐
= new calendar()
Via npm
npm package will be avabile soon
Usage
calendar use a ๐
.set( first_year, last_year )
function to inizialize a calendar that goes from one year(first_year
) to another(last_year
). Once done you can quickly get your calendar.
// let's get the calendar from 1987 to 1997
๐
.set( 1987, 1999 )
console.log(console.log(`this is the calendar from 1987 to 1999` ); )
console.log(๐
.getCalendar())
The output, if you are testing on a browser should be like this:
Now each listed object rappresent a year with all his days also in the form of a list:
Get a specific day
At this point we can point to a certain position to get a specific day:
console.log(`The PlayStation is launched by Sony in Japan ๐ฎ : ` );
๐
.pointDay(12,3,1990)
console.log(๐
.getPointedDay());
Output:
browse between days
Passing an Int
the function below provide a more declarative way to move the pointer:
console.log(๐
.addDays(10));
console.log(๐
.subDays(3));
Output :
๐
RoadMap - Add a getToday method
- Add a getCurrentWeek method
- Add a getPointedWeek
- Add a addWeek and subWeek