datetime-helpers
provides functions to work with dates and time.
import { getLocalizedDayOfWeek } from 'datetime-helpers';
getLocalizedDayOfWeek('en', DayOfWeek.Wednesday)
// returns the localized day of week name for English language
/*
{
isoNumber: 3,
name: {
narrow: 'W',
short: 'Wed',
long: 'Wednesday'
}
}
*/
import { DayOfWeek, getLocalizedDaysOfWeek } from 'datetime-helpers';
getLocalizedDaysOfWeek('en-UK')
// returns a list of the 7 days of week, starting from Monday
getLocalizedDaysOfWeek('en-UK', DayOfWeek.Sunday)
// returns a list of the 7 days of week, starting from Sunday
import { DayOfWeek, getMonthGrid } from 'datetime-helpers';
getMonthGrid(Temporal.PlainYearMonth.from({ year: 2022, month: 10 }))
// returns the month grid for October 2022, with weeks starting on Monday
// the grid is a 2-dimensional array (6 weeks x 7 days of week)
getMonthGrid(Temporal.PlainYearMonth.from({ year: 2022, month: 10 }), DayOfWeek.Sunday)
// returns the month grid for October 2022, with weeks starting on Sunday
You can get datetime-helpers
via npm.
npm install datetime-helpers