moment / luxon

⏱ A library for working with dates and times in JS
https://moment.github.io/luxon
MIT License
15.32k stars 730 forks source link

Interval.toLocaleString fails for Mobile Safari 14.0.3 #1536

Open halmeen opened 11 months ago

halmeen commented 11 months ago

Describe the bug Interval.toLocaleString fails for Mobile Safari 14.0.3 with the error: TypeError: this.dtFormatter(e.start,n).dtf.formatRange is not a function. (In 'this.dtFormatter(e.start,n).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())', 'this.dtFormatter(e.start,n).dtf.formatRange' is undefined)

To Reproduce Use Interval.toLocaleString in Mobile Safari 14.0.3 Example code:

import { DateTime, Interval } from 'luxon';

Interval.fromDateTimes(
  new Date('2023-11-10T00:00:00Z'),
  new Date('2023-11-20T00:00:00Z')
).toLocaleString(DateTime.DATE_MED_WITH_WEEKDAY);

Actual vs Expected behavior Actual: TypeError as described above Expected: No error

Desktop (please complete the following information):

Additional context

diesieben07 commented 11 months ago

This is an issue with the documentation, Interval#toLocaleString requires the browser to support Intl.DateTimeFormat#formatRange. iOS Safari only supports this starting with version 14.5.