exiftool-vendored
    Preparing search index...

    Function equivalentZones

    • Check if two timezone values are equivalent at a specific point in time.

      Two zones are considered equivalent if they:

      • Are the same zone (via Luxon's Zone.equals()), OR
      • Have the same offset at the specified timestamp

      This is useful for:

      • De-duplicating timezone records
      • Comparing zones in different formats ("UTC+5" vs "UTC+05:00")
      • Matching IANA zones to their offset at a specific time

      For IANA zones with DST, you can specify a timestamp to evaluate equivalence at that moment. This is important when comparing historical records or future events where DST transitions matter.

      Parameters

      • a: Maybe<string | number | Zone<boolean>>

        First timezone (Zone, string, or offset in minutes)

      • b: Maybe<string | number | Zone<boolean>>

        Second timezone (Zone, string, or offset in minutes)

      • at: number = ...

        Timestamp in milliseconds to evaluate zone offsets. Defaults to current time (Date.now()).

      Returns boolean

      true if zones are equivalent at the specified time

      // Same zone, different formats
      equivalentZones("UTC+5", "UTC+05:00") // true
      equivalentZones("UTC-8", -480) // true (480 minutes = 8 hours)
      equivalentZones("GMT", "UTC") // true
      equivalentZones("Z", 0) // true

      // IANA zones matched by current offset (default behavior)
      equivalentZones("America/New_York", "UTC-5") // true in winter (EST)
      equivalentZones("America/New_York", "UTC-4") // true in summer (EDT)

      // IANA zones at specific times
      const winter = new Date("2023-01-15").getTime()
      const summer = new Date("2023-07-15").getTime()
      equivalentZones("America/New_York", "UTC-5", winter) // true (EST)
      equivalentZones("America/New_York", "UTC-4", winter) // false (not EDT in winter)
      equivalentZones("America/New_York", "UTC-4", summer) // true (EDT)
      equivalentZones("America/New_York", "UTC-5", summer) // false (not EST in summer)

      // Compare two IANA zones at a specific time
      equivalentZones("America/New_York", "America/Toronto", winter) // true (both EST)
      equivalentZones("America/New_York", "America/Los_Angeles", winter) // false (EST vs PST)

      // Different zones
      equivalentZones("UTC+8", "UTC+9") // false

      // Invalid zones return false
      equivalentZones("invalid", "UTC") // false
      equivalentZones(null, "UTC") // false