diff --git a/README.md b/README.md index 92bcf3e7..2e582db7 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,10 @@ Given those constraints, version numbers follow standard SemVer, with the follow ## Changelog +### v2.12.0 + +* 🐛 Fixed [`gps.toDate is not a function`](https://github.com/mceachen/exiftool-vendored.js/issues/3) + ### v2.11.0 * 🌱 ExifTool upgraded to v10.47 diff --git a/src/tags_task.spec.ts b/src/tags_task.spec.ts index 4addf8bc..3468ab2f 100644 --- a/src/tags_task.spec.ts +++ b/src/tags_task.spec.ts @@ -75,6 +75,14 @@ describe("TimeZone extraction", () => { expect(t.DateTimeOriginal.tzoffsetMinutes).to.eql(8 * 60) expect(t.DateTimeCreated.tzoffsetMinutes).to.eql(8 * 60) }) + + it("skips invalid timestamps", () => { + const t = parse({ + DateTimeOriginal: "2016:08:12 13:28:50", + GPSDateTime: "not a timestamp", + }) + expect(t.DateTimeOriginal.tzoffsetMinutes).to.be.undefined + }) }) describe("SubSecDateTimeOriginal", () => { diff --git a/src/tags_task.ts b/src/tags_task.ts index b545fc28..c9108df5 100644 --- a/src/tags_task.ts +++ b/src/tags_task.ts @@ -46,14 +46,14 @@ export class TagsTask extends Task { } private extractTzoffset(): void { - // TimeZone just wins if we're just handed it, then use it: + // TimeZone wins if we've got it: const tze = new _dt.ExifTimeZoneOffset("TimeZone", this.rawTags.TimeZone) if (tze.tzOffsetMinutes !== undefined) { this.tzoffset = tze.tzOffsetMinutes - } else { + } else if (this.rawTags.GPSDateTime != null && this.rawTags.DateTimeOriginal != null) { const gps = _dt.parse("GPSDateTime", this.rawTags.GPSDateTime, 0) as _dt.ExifDateTime const local = _dt.parse("DateTimeOriginal", this.rawTags.DateTimeOriginal, 0) as _dt.ExifDateTime - if (gps && local) { + if (gps && local && gps.toDate && local.toDate) { // timezone offsets are never less than 30 minutes. const gpsToHalfHour = gps.toDate().getTime() / (30 * 60 * 1000) const localToHalfHour = local.toDate().getTime() / (30 * 60 * 1000)