exiftool-vendored
    Preparing search index...

    Function extractZone

    • Extract timezone information from various value types.

      Handles multiple input formats and performs intelligent parsing:

      • Strings: ISO offsets ("+08:00"), IANA zones, UTC variants, timestamps with embedded timezones ("2023:01:15 10:30:00-08:00")
      • Numbers: Hour offsets (e.g., -8 for UTC-8)
      • Arrays: Uses first non-null value
      • ExifDateTime/ExifTime instances: Extracts their zone property

      By default, strips timezone abbreviations (PST, PDT, etc.) as they are ambiguous. Returns provenance information indicating which parsing method succeeded.

      Supports Unicode minus signs (−, U+2212) and plus-minus signs (±, U+00B1) in addition to ASCII +/-.

      Parameters

      • value: unknown

        Value to extract timezone from

      • Optionalopts: { stripTZA?: boolean }
        • OptionalstripTZA?: boolean

          Whether to strip timezone abbreviations (default: true). TZAs like "PST" are ambiguous and usually stripped.

      Returns Maybe<TzSrc>

      TzSrc with zone name and provenance, or undefined if no timezone found

      // ISO offset strings
      extractZone("+08:00")
      // { zone: "UTC+8", tz: "UTC+8", src: "offsetMinutesToZoneName" }

      extractZone("UTC-5:30")
      // { zone: "UTC-5:30", tz: "UTC-5:30", src: "normalizeZone" }

      // IANA zone names
      extractZone("America/Los_Angeles")
      // { zone: "America/Los_Angeles", tz: "America/Los_Angeles", src: "normalizeZone" }

      // Timestamps with embedded timezones
      extractZone("2023:01:15 10:30:00-08:00")
      // { zone: "UTC-8", tz: "UTC-8", src: "offsetMinutesToZoneName",
      // leftovers: "2023:01:15 10:30:00" }

      // Unicode minus signs
      extractZone("−08:00") // Unicode minus (U+2212)
      // { zone: "UTC-8", tz: "UTC-8", src: "offsetMinutesToZoneName" }

      // Numeric hour offsets
      extractZone(-8)
      // { zone: "UTC-8", tz: "UTC-8", src: "hourOffset" }

      // Arrays (uses first non-null)
      extractZone([null, "+05:30", undefined])
      // { zone: "UTC+5:30", tz: "UTC+5:30", src: "offsetMinutesToZoneName" }

      // Strips timezone abbreviations by default
      extractZone("2023:01:15 10:30:00-08:00 PST")
      // { zone: "UTC-8", tz: "UTC-8", src: "offsetMinutesToZoneName",
      // leftovers: "2023:01:15 10:30:00" }

      // Invalid inputs return undefined
      extractZone("invalid") // undefined
      extractZone(null) // undefined