Skip to content

"Missing internal slot calendar-id" error on iOS in React Native #344

@AlteredConstants

Description

@AlteredConstants

When calling toLocaleString on any of the date-time classes in a React Native app on an iOS device, I receive the error "Missing internal slot calendar-id".

I believe the problem is that Intl.DateTimeFormat().resolvedOptions().calendar is undefined on that platform currently (a recent change from Apple, I believe) and it's not clear to me from the description in MDN whether this is valid per the spec or not.

I suspect this is likely an issue with React Native, not specifically this library, so I've reported it there also, but I figured I'd open a report here as well in the hopes that it's possible to handle this scenario more gracefully.

Reproduction

You can see the issue with this Expo Snack by clicking the "Launch Snack" button (with iOS selected) here:
https://snack.expo.dev/@miramar-zeff/temporal-ios-tolocalestring-bug?platform=ios

The essential part is this call to toLocaleString:

Temporal.Now.plainDateISO().toLocaleString()

Workaround

Interestingly, using Intl.DateTimeFormat directly instead does work (though obviously much more awkward, verbose, and potentially limiting):

Intl.DateTimeFormat().format(
  new Date(
    Temporal.Now.plainDateISO().toZonedDateTime(
      Temporal.Now.timeZoneId()
    ).epochMilliseconds
  )
)

https://snack.expo.dev/@miramar-zeff/temporal-ios-tolocalestring-workaround?platform=ios

I'm not sure if this is because the implementation of Intl.DateTimeFormat on React Native is handling this missing calendar value more appropriately, using some other value on iOS for this information, or just not using it at all.

Edit: It also looks like the fullcalendar polyfill doesn't have this issue. Not sure if they're just not doing a check that should be happening or if they're handling this case correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions