Skip to content

"toHuman" uses Intl.ListFormat, which isn't supported by Safari < 14.1 #1189

Open
@distinctdan

Description

@distinctdan

Describe the bug
I have a user who's on an older version of Safari, and they're getting an error about Intl.ListFormat. Looking through the luxon source, it looks like it's coming from toHuman. Unfortunately, Intl.ListFormat isn't supported by older versions of safari. Here's the error message (manually typed from a screenshot):

TypeError: undefined is not a constructor (evaluating "new Intl.ListFormat(e, t)")

It looks like this was added to luxon fairly recently, here's the place in the source:

dtf = new Intl.ListFormat(locString, opts);

To Reproduce
Please share a minimal code example that triggers the problem:
I haven't been able to get a stack trace from our user, but here's where I think it's coming from:

dur.shiftTo('days').toHuman({
    unitDisplay: 'short',
    maximumFractionDigits: 1,
});

Desktop (please complete the following information):

  • OS: [OSX]
  • Browser [Safari, unknown version, sorry]
  • Luxon version [2.3.0]
  • Your timezone [America/New_York]

Additional context
CanIUse: https://caniuse.com/?search=intl.listFormat
This is also referenced here by this feature discussion: #688 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions