1.0.2 • Published 2 years ago

@ymirthor/date-utils v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

codecov

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);