@karmaniverous/rrstack
    Preparing search index...

    Function wallTimeToEpoch

    • Interprets a Date's UTC Y/M/D/H/M/S as a wall-clock time in timezone and returns the epoch in the configured unit.

      Notes

      • The Date's UTC fields are used intentionally so a "floating" Date produced by epochToWallDate round-trips deterministically.

      Parameters

      • date: Date

        JS Date whose UTC fields (getUTCFullYear(), getUTCMonth(), etc.) represent the intended wall-clock Y/M/D/H/M/S in the supplied IANA time zone. If date.getTime() is NaN, a RangeError('Invalid Date') is thrown.

      • timezone: TimeZoneId

        IANA time zone identifier (branded TimeZoneId). If not recognized by the host ICU/Intl data, a RangeError('Invalid time zone') is thrown.

      • timeUnit: UnixTimeUnit = DEFAULT_TIME_UNIT

        Target epoch unit: 'ms' for milliseconds or 's' for integer seconds. Any other value causes RangeError('Invalid time unit').

      Returns number

      Epoch timestamp in the requested unit. In 's' mode, returns truncated integer seconds (Math.trunc).

      RangeError - On invalid Date, invalid time zone, or invalid unit.

      DST behavior:

      • Forward jump (skipped hour): invalid wall times map to the earliest valid instant at/after the requested time in the timezone (e.g., 02:30 → 03:00).
      • Backward (ambiguous): resolves to the earlier offset by Luxon defaults.
      const tz = RRStack.asTimeZoneId('America/New_York');
      const wall = new Date(Date.UTC(2025, 0, 1, 9, 0, 0)); // 09:00 (floating)
      const t = wallTimeToEpoch(wall, tz, 'ms'); // epoch for 2025-01-01 09:00 NY