getweek
v1.0.1
Published
Helpful functions for week info.
Downloads
126
Readme
getWeek
A lightweight npm library for working with dates and weeks.
Installation
To install getWeek
, use npm:
npm install getweek
Usage
Import the functions from getWeek
:
import { getDatesFromWeek, getDatesFromSameWeek, getWeekNumber, isSameWeek } from 'get-week';
getDatesFromWeek
Get an array of dates within a specific week and year.
const weekDates = getDatesFromWeek(week, year);
Returns an array of Date
objects representing the dates within the specified week.
getDatesFromSameWeek
Get an array of dates within the same week as a given date.
const weekDates = getDatesFromSameWeek(date);
Returns an array of Date
objects representing the dates within the same week as the reference date.
getWeekNumber
Get the week number of a given date.
const weekNumber = getWeekNumber(date);
Returns the week number of the given date.
isSameWeek
Check if two dates fall within the same week.
const sameWeek = isSameWeek(date1, date2);
Returns true
if the two dates fall within the same week, false
otherwise.