@northguild/gmt
Version:
Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.
25 lines (23 loc) • 993 B
JavaScript
import { isFiscalExtraWeekName } from "../../internal/unitNames.js";
// src/calendar/validate/isValidFiscalExtraWeek.ts
/**
* Return true when `value` is a valid FiscalExtraWeek: the period a 53rd week is added to.
*
* - Valid values are `"firstPeriod"` and `"lastPeriod"`. The ONS retail trading periods (UK)
* add a five-week January; the NRF 4-5-4 calendar (US) adds the week to the end.
* - Accepts any input type and returns false for non-string values.
* - Use it to narrow a value read from config, an env var or a form before building a
* `FiscalCalendar`.
*
* @param value candidate value of any type
* @returns boolean indicating validity
*
* @example isValidFiscalExtraWeek("firstPeriod") // true
* @example isValidFiscalExtraWeek("lastPeriod") // true
* @example isValidFiscalExtraWeek("lastQuarter") // false
* @example isValidFiscalExtraWeek(12) // false
*/
function isValidFiscalExtraWeek(value) {
return isFiscalExtraWeekName(value);
}
export { isValidFiscalExtraWeek };