2.0.3 • Published 1 year ago

calendar-view-utils v2.0.3

Weekly downloads
17
License
MIT
Repository
github
Last release
1 year ago

NPM Version CI codecov

Calendar View Utilities

Utilities for building calendar views.

Live demo

Table of Contents

Features

  • 📅 Tools to create your own UI or component.
  • 🛠 Works with native Date objects, no library required.
  • 🎉 Written in TypeScript.

Installation

npm install calendar-view-utils --save

Usage

import { CalendarMonth } from 'calendar-view-utils';

const date = new Date(2021, 0, 1);

const view = new CalendarMonth(date);
console.log(view);

CalendarMonth

Create a CalendarMonth for the target date. A CalendarMonth contains all the needed information for building a standard month view.

new CalendarMonth(date);
PropertyDescriptionType
yearYear valuenumber
monthMonth valuenumber
weeksCollection of weeks with the monthCalendarWeek[]

CalendarWeek

Create a CalendarWeek for the target date. A CalendarWeek contains all the needed information for building a standard week view.

new CalendarWeek(date);
PropertyDescriptionType
isoWeekISO week valuenumber
daysCollection of days within the weekCalendarDay[]

CalendarDay

Create a CalendarDay for the target date.

new CalendarDay(date);
PropertyDescriptionType
isoStringISO string value (date)string
dayDay of month valuenumber
monthMonth valuenumber
yearYear valuenumber
isTodayIndicates if the day is today.boolean
isPastIndicates if the day is before todayboolean
isFutureIndicates if the day is after todayboolean

Options

import { DayOfWeek } from 'calendar-view-utils';

const options = {
  weekStartsOn: DayOfWeek.Monday,
};

const view = new CalendarWeek(date, options);
PropertyDescriptionTypeDefault
weekStartsOnWhich day the week starts onDayOfWeekSunday

Utilities

import { DayOfWeek, getWeekDays } from 'calendar-view-utils';

const example1 = getWeekDays();
// => [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]

const example2 = getWeekDays(DayOfWeek.Monday);
// => [Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday]

Development

npm install
npm run build
2.0.3

1 year ago

2.0.2

2 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago