Skip to content

Commit 5fd3a60

Browse files
committed
fix(useDate): fall back to deprecated weekInfo when getWeekInfo is unavailable
deriveFirstDayOfWeek only checked Intl.Locale.getWeekInfo(), which is absent on the older ICU shipped with current LTS Node. The v0 date adapter already handles both forms; mirror that fallback in the helper so locale-driven first-day derivation works in CI.
1 parent c8f0448 commit 5fd3a60

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • packages/0/src/composables/useDate

packages/0/src/composables/useDate/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,12 @@ const defaultLocales: Record<string, string> = {
118118
*/
119119
function deriveFirstDayOfWeek (locale: string): number {
120120
try {
121-
const loc = new Intl.Locale(locale) as Intl.Locale & { getWeekInfo?: () => { firstDay: number } }
122-
const info = loc.getWeekInfo?.()
121+
const loc = new Intl.Locale(locale) as Intl.Locale & {
122+
getWeekInfo?: () => { firstDay: number }
123+
weekInfo?: { firstDay: number }
124+
}
125+
// Newer Node/ICU exposes getWeekInfo(); older Node exposes the deprecated weekInfo property.
126+
const info = loc.getWeekInfo?.() ?? loc.weekInfo
123127
return info ? info.firstDay % 7 : 0 // ISO 1-7 → v0 0-6
124128
} catch {
125129
return 0

0 commit comments

Comments
 (0)