Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

calendar-view-utils

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

calendar-view-utils

Utilities for generating calendar views.

  • 2.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-41.18%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 23 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc