0.8.0 • Published 11 months ago

datetime-helpers v0.8.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
11 months ago

datetime-helpers

datetime-helpers provides functions to work with dates and time.

Day of week helpers

getLocalizedDayOfWeek

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'
  }
}
*/

getLocalizedDaysOfWeek

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

Month helpers

getMonthGrid

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

Install

You can get datetime-helpers via npm.

npm install datetime-helpers
0.8.0

11 months ago

0.7.0

11 months ago

0.6.0

12 months ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago