UNPKG

@qntm-code/utils

Version:

A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.

17 lines (16 loc) 634 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getMonthNames = void 0; /** * Gets the month names for the provided locale. Defaults to the browser's locale. Optionally, you can provide a format. */ function getMonthNames(options) { const { locale, format } = { locale: navigator.language, format: 'long', ...options }; const formatter = new Intl.DateTimeFormat(locale, { month: format }); const monthNames = []; for (let i = 0; i < 12; i++) { monthNames.push(formatter.format(new Date(1970, i, 1))); } return monthNames; } exports.getMonthNames = getMonthNames;