@kotonosora-tech/date-utils
TypeScript icon, indicating that this package has built-in type declarations

1.0.12 • Public • Published

Date Utils

A small tool calculator calendar in month

version MIT License


Table of Contents

Installation

npm install @kotonosora-tech/date-utils --save
# or with yarn
yarn add @kotonosora-tech/date-utils

Features

Get Key Month

Return from date, to date available of month by select day, month start date, action change start date and holidays in a round year

getKeyMonthFromToDate(param);
Example:

import { getKeyMonthFromToDate, DateKeyFormat, MonthlyStartDateAction } from '@kotonosora-tech/date-utils';

const holidays: string[] = [
  '2020-01-01',
  '2020-04-30',
  '2020-05-01',
  '2020-09-02',
]

const result = getKeyMonthFromToDate(
  new Date(),
  1,
  MonthlyStartDateAction.NoChange,
  holidays
);

/**
{
  keyMonth: '2022-07-01-2022-07-31',
  fromDate: '2022-07-01',
  toDate: '2022-07-31'
}
* /

Get Page Month

Return list string format YYYY-MM-DD of page calendar by first day of week, from and to date

getPageMonth(param: IPageMonth): string[]
Example:

import {getPageMonth, FIRST_DAY_OF_WEEK} from "@kotonosora-tech/date-utils";

let result: string[] = getPageMonth(
  FIRST_DAY_OF_WEEK.MONDAY,
  new Date(2020, 6, 10),
  new Date(2020, 7, 5)
);

/**
result = [
  '2020-06-08',
  '2020-06-09',
  ...
  '2020-07-11',
  '2020-07-12'
];
* /

Authors

Nguyễn Duy Thắng

License

MIT

Package Sidebar

Install

npm i @kotonosora-tech/date-utils

Weekly Downloads

0

Version

1.0.12

License

MIT

Unpacked Size

9.69 kB

Total Files

16

Last publish

Collaborators

  • kotonosora