Skip to content

iso

Imported from yugajs/extension/iso.

const iso: yuga.Extension<void>;

Reads the ISO 8601 and RFC 9557 strings core doesn’t (yuga() keeps reading the rest the same):

  • RFC 9557 annotations, Temporal’s toString (2024-05-15T10:20:30+02:00[Europe/Paris]): the moment, and the instance is in that time zone. An offset the time zone doesn’t have at that wall clock is invalid (Temporal’s "reject"), so are calendars other than ISO’s. yuga(instance.toTemporal().toString()) is the same instance.
  • The basic format (20240515T102030+0200), hour-only offsets (+02), offsets with seconds (+05:30:15) and comma fractions (10:20:30,5).
  • Week dates (2024-W20-3) and ordinal dates (2024-136), in the instance’s time zone like 2024-05-15.

Core reads every string first and gives this extension the ones it can’t (parseString, zoneOf). Week and ordinal dates become calendar dates that core reads, the other strings that ISO matches are read by Temporal (ZonedDateTime, Instant, or a PlainDateTime that core reads in the instance’s time zone). Strings it doesn’t match are left to Date.