@ymirthor/date-utils
v1.0.2
Published
[![codecov](https://codecov.io/gh/ymirthor/T-533-VIHU-A2/branch/main/graph/badge.svg?token=4RWSG6HZGL)](https://codecov.io/gh/ymirthor/T-533-VIHU-A2)
Downloads
2
Maintainers
Readme
Assignment 3 - Github Actions
Author: @ymirthor
Installation
npm install @ymirthor/date-utils
How to use
// Import in your .ts project
import {
getCurrentYear,
add,
isWithinRange,
isDateBefore,
isSameDay,
} from '@ymirthor/date-utils';
// Example of how to use
const today = new Date(2022, 0, 1);
const currentYear = getCurrentYear(today);
assert(currentYear === 2022);
const nextYear = add(today, { years: 1 });
assert(nextYear === new Date(2023, 0, 1));
const isWithinRangeExample = isWithinRange(today, {
start: new Date(2020, 0, 1),
end: new Date(2025, 0, 1),
});
assert(isWithinRangeExample === true);
const isDateBeforeExample = isDateBefore(today, new Date(2025, 0, 1));
assert(isDateBeforeExample === true);
const isSameDayExample = isSameDay(today, new Date(2022, 0, 1));
assert(isSameDayExample === true);