@karmaniverous/rrstack
    Preparing search index...

    Function epochToWallDate

    • Convert an epoch in the given unit to a JS Date carrying the same local clock in timezone (a "floating" Date). The returned Date's UTC fields (getUTC*) reflect the local time in timezone at that instant; this shape is convenient for UI round-trips with wallTimeToEpoch.

      Parameters

      • epoch: number

        Epoch timestamp in the provided unit.

      • timezone: TimeZoneId

        IANA time zone identifier (branded TimeZoneId). Throws RangeError on invalid zone.

      • timeUnit: UnixTimeUnit = DEFAULT_TIME_UNIT

        'ms' (default) for milliseconds or 's' for integer seconds. Throws RangeError on invalid value.

      Returns Date

      A "floating" Date whose UTC fields equal the local wall-clock Y/M/D/H/M/S in timezone at the provided instant. This is suitable for round- tripping with wallTimeToEpoch.

      In 's' mode, the instant is interpreted as integer seconds since epoch. DST is handled by Luxon at the instant being converted.

      const tz = RRStack.asTimeZoneId('Europe/Paris');
      const wall = epochToWallDate(Date.UTC(2024, 6, 20, 7, 0, 0), tz, 'ms');
      // wall.getUTCHours() equals the Paris local hour at that instant.
      const back = wallTimeToEpoch(wall, tz, 'ms'); // round-trip