Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ai/contributing/decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Active package decisions grouped by area, newest first.

### Arithmetic, Boundaries, and Weekdays

- **D19:** `isWeekend()` and `isWeekday()` follow the locale (2026-11-22) [L113-L117](decisions/package.md#d19-isweekend-and-isweekday-follow-the-locale-2026-11-22)
- Reopen: bug reports show `.locale()` unexpectedly changing `isWeekend()`, `isWeekday()`, or `count('weekdays')`, or users ask for a `configure()` weekend override.
- **D27:** `isWeekend()` and `isWeekday()` follow the locale, but `configure({ weekend })` overrides instance locales (2026-11-25) [L161-L165](decisions/package.md#d27-isweekend-and-isweekday-follow-the-locale-but-configure-weekend--overrides-instance-locales-2026-11-25)
- Reopen: apps serving regions with different workweeks in one process ask for a per-call or per-instance weekend override.
- **D17:** Adjacent unit boundaries use `startOfNext()` and `startOfPrevious()` instead of overloading `next()` and `previous()` (2026-11-19) [L101-L105](decisions/package.md#d17-adjacent-unit-boundaries-use-startofnext-and-startofprevious-instead-of-overloading-next-and-previous-2026-11-19)
- Reopen: cold-reader studies or user issues show developers trying unit names in `next()` and `previous()`, or passing numeric weekdays to `startOfNext()`.
- **D14:** Numeric day of the week is `dayOfWeek` (`1`-`7`) while token `d` keeps Moment's `0`-`6` (2026-11-17) [L83-L87](decisions/package.md#d14-numeric-day-of-the-week-is-dayofweek-1-7-while-token-d-keeps-moments-0-6-2026-11-17)
Expand Down Expand Up @@ -119,7 +119,7 @@ Every package decision (`D1`..`Dn`) in file order.
- **D18:** `native-dates/helpers/*` stays open for official plugins without semver guarantees (2026-11-20) [L107-L111](decisions/package.md#d18-native-dateshelpers-stays-open-for-official-plugins-without-semver-guarantees-2026-11-20)
- Reopen: external packages depend on `native-dates/helpers/*` directly and report breakage across minor releases.
- **D19:** `isWeekend()` and `isWeekday()` follow the locale (2026-11-22) [L113-L117](decisions/package.md#d19-isweekend-and-isweekday-follow-the-locale-2026-11-22)
- Reopen: bug reports show `.locale()` unexpectedly changing `isWeekend()`, `isWeekday()`, or `count('weekdays')`, or users ask for a `configure()` weekend override.
- Superseded by D27 (2026-11-25)
- **D20:** Loose parsing follows the locale while `monthDay()` and `dayMonth()` keep function-name order (2026-11-22) [L119-L123](decisions/package.md#d20-loose-parsing-follows-the-locale-while-monthday-and-daymonth-keep-function-name-order-2026-11-22)
- Reopen: speakers report a locale's `Intl` short date order diverging from typed input, or unconfigured host locales cause inconsistent `{ loose: true }` results across environments.
- **D21:** Time zone abbreviations inside `{ loose: true }` strings resolve like `{ zone }` rather than `Date.parse()` (2026-11-22) [L125-L129](decisions/package.md#d21-time-zone-abbreviations-inside--loose-true--strings-resolve-like--zone--rather-than-dateparse-2026-11-22)
Expand All @@ -134,3 +134,5 @@ Every package decision (`D1`..`Dn`) in file order.
- Reopen: server apps passing per-request `Accept-Language` headers alongside `configure({ dayFirst: true })` report wanting the configured `dayFirst` setting to override per-call `locale`.
- **D26:** Loose parsing returns `null` unless year, month, and day are all written (2026-11-23) [L155-L159](decisions/package.md#d26-loose-parsing-returns-null-unless-year-month-and-day-are-all-written-2026-11-23)
- Reopen: callers report friction from human-typed current-year dates like `'Nov 16'` returning `null`.
- **D27:** `isWeekend()` and `isWeekday()` follow the locale, but `configure({ weekend })` overrides instance locales (2026-11-25) [L161-L165](decisions/package.md#d27-isweekend-and-isweekday-follow-the-locale-but-configure-weekend--overrides-instance-locales-2026-11-25)
- Reopen: apps serving regions with different workweeks in one process ask for a per-call or per-instance weekend override.
8 changes: 7 additions & 1 deletion ai/contributing/decisions/package.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Reopen: external packages depend on `native-dates/helpers/*` directly and report

Hardcoding Saturday and Sunday (`dayOfWeek >= 6`, as in Moment, Day.js, and date-fns) gets weekends wrong in Friday-Saturday (`ar-SA`, `he-IL`), Friday-only (`fa-IR`), and Sunday-only (`hi-IN`) locales even though `startOf('week')` already localizes via `Intl.Locale.prototype.getWeekInfo` (`D7`). The tradeoff is that `.locale()` changes `isWeekend()`, `isWeekday()`, and `DateRange.prototype.count('weekdays')`, so code needing fixed Saturday-Sunday rules has to check `dayOfWeek >= 6`.

Reopen: bug reports show `.locale()` unexpectedly changing `isWeekend()`, `isWeekday()`, or `count('weekdays')`, or users ask for a `configure()` weekend override.
Superseded by D27 (2026-11-25).

## D20: Loose parsing follows the locale while `monthDay()` and `dayMonth()` keep function-name order (2026-11-22)

Expand Down Expand Up @@ -157,3 +157,9 @@ Reopen: server apps passing per-request `Accept-Language` headers alongside `con
Delegating partial or noisy strings to `Date.parse()` fabricated V8's default year `2001` and day `01` (`'Room 12'` -> `2001-12-01`, `'Nov 16'` -> `2001-11-16`, `'May 2026'` -> `2026-05-01`). Requiring all three date parts in `date()` and `datetime()` under `{ loose: true }` returns `null` instead of invented dates, while partial dates use dedicated factories (`monthDay('Nov 16', { loose: true })`, `yearMonth('May 2026', { loose: true })`).

Reopen: callers report friction from human-typed current-year dates like `'Nov 16'` returning `null`.

## D27: `isWeekend()` and `isWeekday()` follow the locale, but `configure({ weekend })` overrides instance locales (2026-11-25)

Supersedes D19. Weekend checks and weekday range counts follow the active locale by default, while `configure({ weekend })` sets fixed weekend days for the whole process. Letting an instance locale win instead would silently change business-day rules whenever a server formats a date for a visitor. This follows the same priority as `weekStart` and keeps workweeks consistent across requests.

Reopen: apps serving regions with different workweeks in one process ask for a per-call or per-instance weekend override.
5 changes: 3 additions & 2 deletions ai/skills/native-dates.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ datetime('2026-03-08T04:30:00Z', 'UTC');
datetime('2026-03-08T04:30:00Z', 'America/New_York').plus(1, 'day').toJSON(); // '2026-03-09T03:30:00.000Z'
```

**2. `month` is `1`–`12`, `dayOfWeek` is ISO `1`–`7` (`7` = Sun), `isWeekend()`/`isWeekday()` follow the locale, and tokens use Moment casing (`YYYY-MM-DD`, not `yyyy-MM-dd`).** Weekends vary by locale (`ar-SA`/`ar-EG`/`he-IL` Fri–Sat, `fa-IR` Fri, `hi-IN` Sun). In `format()`, `'yyyy'` throws `unknownFormat` (absent noun token like `'HH'` on `CalendarDate` throws `unsupportedToken`), `'dd'` is 2-letter weekday (`'Mo'`), `'E'` is `'1'`–`'7'`, `'d'` is `'0'`–`'6'` (`0` = Sun), and literals glued to accented letters (`'às'`) or `h` after `H` (`'HHhmm'`) need `[brackets]`.
**2. `month` is `1`–`12`, `dayOfWeek` is ISO `1`–`7` (`7` = Sun), `isWeekend()`/`isWeekday()` follow the locale (unless pinned via `configure({ weekend })`), and tokens use Moment casing (`YYYY-MM-DD`, not `yyyy-MM-dd`).** Weekends vary by locale (`ar-SA`/`ar-EG`/`he-IL` Fri–Sat, `fa-IR` Fri, `hi-IN` Sun). In `format()`, `'yyyy'` throws `unknownFormat` (absent noun token like `'HH'` on `CalendarDate` throws `unsupportedToken`), `'dd'` is 2-letter weekday (`'Mo'`), `'E'` is `'1'`–`'7'`, `'d'` is `'0'`–`'6'` (`0` = Sun), and literals glued to accented letters (`'às'`) or `h` after `H` (`'HHhmm'`) need `[brackets]`.

```js
// ❌ date(2026, 0, 15) -> invalidDate; date('2026-11-16').format('yyyy-MM-dd') -> unknownFormat
Expand Down Expand Up @@ -223,6 +223,7 @@ configure({
zone: 'America/New_York', // null resets
locale: 'en-US', // null resets
weekStart: 'monday', // 1..7 or name (null -> locale)
weekend: ['saturday', 'sunday'], // weekday array, [] for none (null -> locale)
formats: { sql: 'YYYY-MM-DD HH:mm:ss' }, // null clears
weekdayNames: { lv: { narrow: { fri: 'Pk', sun: 'Sv' } } },
ordinals: { fr: (day) => (day === 1 ? '1er' : day) },
Expand All @@ -243,7 +244,7 @@ configure({
| Error codes | Thrown when |
|---|---|
| `missingDateTime`, `missingDate`, `missingTime`, `missingMonthDay`, `missingYearMonth`, `missingDay`, `missingPoints`, `missingAnchor`, `missingPlugin`, `missingTemporal` | Nullish input, `date(2026, 11)`, unanchored `months(2).total('days')`, unloaded plugin option, or missing `globalThis.Temporal` in development (`RangeError`; production throws native `ReferenceError`) |
| `invalidDateTime`, `invalidDate`, `invalidTime`, `invalidDuration`, `invalidMonthDay`, `invalidYearMonth`, `invalidRange`, `invalidStep`, `invalidNumber`, `invalidFraction`, `invalidYear`, `invalidDay`, `invalidPoint` | Malformed input, `Feb 30`, rejected DST gap/fold, non-positive step, or `end < start` |
| `invalidDateTime`, `invalidDate`, `invalidTime`, `invalidDuration`, `invalidMonthDay`, `invalidYearMonth`, `invalidRange`, `invalidStep`, `invalidNumber`, `invalidFraction`, `invalidYear`, `invalidDay`, `invalidPoint`, `invalidWeekend` | Malformed input, `Feb 30`, rejected DST gap/fold, non-positive step, `end < start`, or non-array `configure({ weekend })` |
| `cannotAdd`, `cannotSubtract`, `cannotSet`, `cannotRound`, `cannotBalance`, `cannotTotal` | Overflow, invalid `set()` field, or bad rounding increment (`round(7, 'minutes')`) |
| `unknownZone`, `unknownLocale`, `unknownDisambiguation`, `unknownUnit`, `unknownDayOfWeek`, `unknownFormat`, `unknownKind`, `unknownSetting`, `unknownWidth` | Bad zone, BCP 47 tag, `disambiguation`, unit, weekday, token/preset (`'yyyy'`), `as()`/`count()` target, or `configure()` key |
| `unsupportedUnit`, `unsupportedToken`, `unsupportedComparison`, `unsupportedZone`, `unsupportedCalendar`, `unsupportedIntersection` | Absent unit/token, `<`/`-` on non-`DateTime`, `timeRange.in()`, non-ISO partial, or double overnight overlap |
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/api/calendar-date.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ Relative day checks accept an optional time zone because which calendar day is t
|---|---|---|
| `isToday(zone?)`, `isTomorrow(zone?)`, `isYesterday(zone?)` | `boolean` | Whether this date matches today, tomorrow, or yesterday in the given or configured zone. |
| `isPast(zone?)`, `isFuture(zone?)` | `boolean` | Whether this date is earlier or later than today in the given or configured zone. |
| `isWeekday()`, `isWeekend()` | `boolean` | Working day vs. weekend day in the active locale, such as Saturday and Sunday in `en-US` or Friday and Saturday in `ar-SA`. |
| `isWeekday()`, `isWeekend()` | `boolean` | Working day vs. weekend day from [`configure({ weekend })`](/api/configure/) or the active locale, such as Saturday and Sunday in `en-US` or Friday and Saturday in `ar-SA`. |
| `isLeapYear()` | `boolean` | Whether this date's year has 366 days. |

## Measuring spans
Expand Down
12 changes: 8 additions & 4 deletions docs/src/content/docs/api/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ datetime('2026-11-16T17:30:00Z').zone; // 'Europe/Berlin'
date('2026-11-18').startOf('week').toString(); // '2026-11-16'
configure().weekStart; // undefined

configure({ weekStart: 'sunday' });
configure({ weekStart: 'sunday', weekend: ['saturday', 'sunday'] });
date('2026-11-18').startOf('week').toString(); // '2026-11-15'
configure().weekStart; // 7
configure().weekend; // [6, 7]

// reset back to the runtime zone, runtime locale, and locale week start
configure({ zone: null, locale: null, weekStart: null });
// reset back to the runtime zone, runtime locale, and locale week rules
configure({ zone: null, locale: null, weekStart: null, weekend: null });
```

**Parameters**
Expand All @@ -56,6 +57,9 @@ configure({ zone: null, locale: null, weekStart: null });
- name: weekStart
type: DayOfWeek | null
description: First day of the week for week boundaries and `weekdayNames()`, from 1 for Monday through 7 for Sunday. Unset or `null` follows the active locale.
- name: weekend
type: readonly DayOfWeek[] | null
description: Weekend days used by `isWeekend()`, `isWeekday()`, and `DateRange.count('weekdays' | 'weekends')`. Overrides per-instance `.locale()` when set; pass `[]` for no weekend days, or `null` to follow the locale.
- name: weekdayNames
type: "Record<Locale, { narrow?, short?, long? }> | null"
description: "Custom weekday labels keyed by language, width (`narrow`, `short`, or `long`), and day name. Regional tags layer over their base language, and an empty value restores runtime names."
Expand All @@ -76,7 +80,7 @@ configure({ zone: null, locale: null, weekStart: null });
**Returns**

```returns
type: "{ zone, locale, weekStart, dayFirst, zoneAliases, weekdayNames, ordinals, formats }"
type: "{ zone, locale, weekStart, weekend, dayFirst, zoneAliases, weekdayNames, ordinals, formats }"
description: A shallow copy of the active settings after applying updates. Unset keys return `undefined`.
```

Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/api/date-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ Zero-argument checks evaluated in the instance's time zone:
|---|---|---|
| `isPast()`, `isFuture()` | `boolean` | Whether this instant is earlier or later than the current time. |
| `isToday()`, `isTomorrow()`, `isYesterday()` | `boolean` | Whether the local calendar date matches today, tomorrow, or yesterday in this zone. |
| `isWeekday()`, `isWeekend()` | `boolean` | Working day vs. weekend day in the active locale, such as Saturday and Sunday in `en-US` or Friday and Saturday in `ar-SA`. |
| `isWeekday()`, `isWeekend()` | `boolean` | Working day vs. weekend day from [`configure({ weekend })`](/api/configure/) or the active locale, such as Saturday and Sunday in `en-US` or Friday and Saturday in `ar-SA`. |
| `isLeapYear()` | `boolean` | Whether the local year is a leap year. |

## Measuring time
Expand Down
1 change: 1 addition & 0 deletions docs/src/content/docs/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Range errors indicate that a value cannot be parsed, falls outside valid bounds,
| `unknownSetting` | `configure()` | Setting key passed to `configure()` is not recognized. |
| `unknownWidth` | `configure()` | A `weekdayNames` entry names a width other than `narrow`, `short`, or `long`, or leaves the width out. |
| `unknownZone` | Factories, `in()`, `configure()` | Unknown IANA time zone ID, non-string zone, or malformed UTC offset. |
| `invalidWeekend` | `configure()` | `weekend` is neither an array of weekdays nor `null`. |
| `invalidZoneAliases` | `configure()` | `zoneAliases` is neither a plain object nor `null`. |
| `unknownLocale` | `locale()`, factories, `format()`, `monthNames()`, `weekdayNames()`, `configure()` | Locale tag, tag list, or `Accept-Language` header contains an invalid language tag. |
| `unknownFormat` | `format()`, `monthNames()`, `weekdayNames()` | Invalid format spec or `Intl` options, unsupported duration or label style, or unrecognized or glued tokens outside `[brackets]`. |
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/api/ranges.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ timeRange('22:00', '02:00').every(1, 'hour').map(String);
dateRange.count(kind?): number
```

Counts calendar days inside a [`DateRange`](#daterange) without allocating intermediate date instances. Pass `'days'` (the default), `'weekdays'`, `'weekends'`, or a weekday name such as `'mondays'`. `'weekdays'` and `'weekends'` follow the active locale's weekend days.
Counts calendar days inside a [`DateRange`](#daterange) without allocating intermediate date instances. Pass `'days'` (the default), `'weekdays'`, `'weekends'`, or a weekday name such as `'mondays'`. `'weekdays'` and `'weekends'` follow [`configure({ weekend })`](/api/configure/) when set, or the active locale's weekend days.

**Parameters**

Expand Down
9 changes: 9 additions & 0 deletions docs/src/content/docs/guides/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@ friday.locale('en-US').isWeekend(); // false
friday.locale('ar-SA').isWeekend(); // true
```

Set `weekend` in [`configure()`](/api/configure/) when an app needs fixed business-day rules across every locale, even on values formatted with `.locale()` for a different region. Pass an array of weekday names or ISO numbers (or `[]` for a seven-day workweek), and pass `null` to follow the locale again:

```js
configure({ weekend: ['saturday', 'sunday'] });

friday.locale('ar-SA').isWeekend(); // false
configure({ weekend: null });
```

## Custom weekday names and ordinals

Month and weekday names come from the runtime, matching what the reader's device prints. Two format tokens have no standard platform field: two-letter weekdays with `dd`, and day ordinals with `Do`.
Expand Down
5 changes: 4 additions & 1 deletion docs/src/content/translations/ar/docs/api/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ configure({ zone: null, locale: null, weekStart: null });
- name: weekStart
type: DayOfWeek | null
description: اليوم الأول في الأسبوع لحدود الأسابيع و`weekdayNames()`، باسم يوم من أيام الأسبوع بالإنجليزية أو رقم من 1 ليوم الاثنين حتى 7 ليوم الأحد؛ ويتبع عدم ضبطه أو تمرير `null` الإعداد المحلي النشط.
- name: weekend
type: readonly DayOfWeek[] | null
description: "أيام عطلة نهاية الأسبوع المستخدمة في `isWeekend()` و`isWeekday()` و`DateRange.count('weekdays' | 'weekends')`. يتغلب ضبطها على `.locale()` لكل مثيل؛ مرر `[]` لعدم وجود عطلة أو `null` لاتباع الإعداد المحلي."
- name: weekdayNames
type: "Record<Locale, { narrow?, short?, long? }> | null"
description: تسميات مخصّصة لأيام الأسبوع مفهرسة بوسم الإعداد المحلي وعرض التسمية (`narrow` أو `short` أو `long`) واسم اليوم بالإنجليزية؛ وتتراكب الوسوم الإقليمية فوق وسم لغتها الأساسي، بينما تستعيد القيمة الفارغة أسماء بيئة التشغيل.
Expand All @@ -73,7 +76,7 @@ configure({ zone: null, locale: null, weekStart: null });
**القيمة المُرجَعة**

```returns
type: "{ zone, locale, weekStart, dayFirst, zoneAliases, weekdayNames, ordinals, formats }"
type: "{ zone, locale, weekStart, weekend, dayFirst, zoneAliases, weekdayNames, ordinals, formats }"
description: نسخة سطحية من الإعدادات النشطة بعد تطبيق التحديثات، مع القيمة `undefined` للمفاتيح غير المضبوطة.
```

Expand Down
5 changes: 4 additions & 1 deletion docs/src/content/translations/es/docs/api/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ configure({ zone: null, locale: null, weekStart: null });
- name: weekStart
type: DayOfWeek | null
description: Primer día de la semana para límites semanales y `weekdayNames()`, como nombre de día en inglés o número del 1 (lunes) al 7 (domingo). Si se omite o es `null`, sigue el locale activo.
- name: weekend
type: readonly DayOfWeek[] | null
description: "Días de fin de semana usados por `isWeekend()`, `isWeekday()` y `DateRange.count('weekdays' | 'weekends')`. Prevalece sobre `.locale()` de cada instancia; pasa `[]` para ningún día de fin de semana o `null` para seguir el locale."
- name: weekdayNames
type: "Record<Locale, { narrow?, short?, long? }> | null"
description: "Etiquetas personalizadas de días de la semana indexadas por locale, anchura (`narrow`, `short` o `long`) y nombre de día en inglés. Las etiquetas regionales se superponen al idioma base y un valor vacío restablece los nombres del entorno."
Expand All @@ -73,7 +76,7 @@ configure({ zone: null, locale: null, weekStart: null });
**Devuelve**

```returns
type: "{ zone, locale, weekStart, dayFirst, zoneAliases, weekdayNames, ordinals, formats }"
type: "{ zone, locale, weekStart, weekend, dayFirst, zoneAliases, weekdayNames, ordinals, formats }"
description: Copia superficial de la configuración activa tras aplicar los cambios. Las claves sin configurar tienen el valor `undefined`.
```

Expand Down
Loading