Skip to content

Commit

Permalink
fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
mceachen committed Mar 27, 2017
1 parent 54c78c7 commit 578d452
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/tags_task.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
6 changes: 3 additions & 3 deletions src/tags_task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ export class TagsTask extends Task<Tags> {
}

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)
Expand Down

0 comments on commit 578d452

Please sign in to comment.