Tags object with timestamp fields
TzSrc with inferred timezone and provenance, or undefined if inference is not possible
extractTzOffsetFromTags to check explicit timezone tags first
// GPS-based inference
const tags = {
DateTimeOriginal: "2023:01:15 11:30:00", // Local time (PST)
GPSDateTime: "2023:01:15 19:30:00" // UTC
}
extractTzOffsetFromUTCOffset(tags)
// { zone: "UTC-8", tz: "UTC-8",
// src: "offset between DateTimeOriginal and GPSDateTime" }
// DateTimeUTC-based inference
const tags2 = {
CreateDate: "2023:07:20 14:15:30", // Local time (JST)
DateTimeUTC: "2023:07:20 05:15:30" // UTC
}
extractTzOffsetFromUTCOffset(tags2)
// { zone: "UTC+9", tz: "UTC+9",
// src: "offset between CreateDate and DateTimeUTC" }
// Handles clock drift
const tags3 = {
DateTimeOriginal: "2023:01:15 11:30:45", // Local with drift
GPSDateTime: "2023:01:15 19:29:58" // UTC (old GPS fix)
}
extractTzOffsetFromUTCOffset(tags3)
// Still infers UTC-8 despite ~1 minute drift
// No UTC timestamp available
const tags4 = {
DateTimeOriginal: "2023:01:15 11:30:00"
// No GPS or UTC timestamp
}
extractTzOffsetFromUTCOffset(tags4) // undefined
Infer timezone offset by comparing local time with GPS/UTC time.
Calculates the timezone by finding the difference between:
Uses inferLikelyOffsetMinutes to handle minor clock drift and round to the nearest valid timezone offset.
This is a fallback when explicit timezone tags are not available.