@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.
18 lines (17 loc) • 736 B
JavaScript
// src/internal/resolveWeekStartsOn.ts
/**
* Resolve a `weekStartsOn` option value.
*
* - `undefined` (the option omitted) resolves to `"monday"`, the ISO 8601 week start.
* - `"monday"` and `"sunday"` resolve to themselves.
* - Any other value is invalid and resolves to `null`, which callers map to their sentinel — as
* Temporal's GetOption rejects a string outside the allowed list.
*
* @param weekStartsOn raw option value from caller input
* @returns `"monday"`, `"sunday"`, or `null` when the value is invalid
*/
function resolveWeekStartsOn(weekStartsOn) {
if (weekStartsOn === void 0) return "monday";
return weekStartsOn === "monday" || weekStartsOn === "sunday" ? weekStartsOn : null;
}
export { resolveWeekStartsOn };