@knownasrazi/calendar
v1.0.0
Published
Calendar helpers: week number, leap year, days in month and date arithmetic.
Downloads
36
Maintainers
Readme
calendar
Calendar helpers: leap year, week, date math.
Zero dependencies - ~2 KB gzipped - TypeScript - Node + Bun + browser
Install
bun add @knownasrazi/calendar
npm install @knownasrazi/calendarUsage
import { isLeapYear, daysInMonth, weekNumber, addDays, addMonths, startOfWeek } from "@knownasrazi/calendar";
isLeapYear(2020); // true
daysInMonth(2020, 2); // 29
weekNumber(new Date("2023-01-01")); // ISO week
addDays(new Date("2023-01-01"), 5);
addMonths(new Date("2023-01-31"), 1); // 2023-02-28 (clamped)
startOfWeek(new Date("2023-01-04"), "mon").getDay(); // 1API
| Export | Description |
| --- | --- |
| isLeapYear(y) | leap year check |
| daysInMonth(y,m) | 28-31 |
| weekNumber(date, start?) | ISO week |
| addDays/addMonths/addYears(date,n) | date arithmetic |
| startOfWeek/endOfWeek(date, start?) | week bounds |
| formatISO(date) | YYYY-MM-DD |
Development
git clone https://github.com/knownasrazi/calendar.git
cd calendar
bun install
bun test
bun run build
bun run lintLicense
calendar - dates without the date-fns.
