Skip to content

Commit

Permalink
restore Exif(Date)?(Time)? parsing for "when" tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mceachen committed Oct 3, 2023
1 parent f574862 commit 9ee6e1f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ vendored versions of ExifTool match the version that they vendor.

## Version history

### v23.3.0

- 🐞 Restored datestamp parsing of `ResourceEvent.When`

### v23.2.0

- ✨ Timezone parsing improvements:

- Added [`ExifToolOptions.inferTimezoneFromDatestampTags`](https://photostructure.github.io/exiftool-vendored.js/interfaces/ExifToolOptions.html#inferTimezoneFromDatestampTags).
- Timezone inference from datestamps now skips over UTC values, as Google
Takeout (and several other applications) may spuriously set "+00:00" to
Expand Down
20 changes: 20 additions & 0 deletions src/ReadTask.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,26 @@ describe("ReadTask", () => {
})
})

it("Resource.When is parsed by ExifDateTime", () => {
const t = parse({
tags: {
History: [
{
Action: "infer",
Changed: "Make",
Parameters: '"ppeggj"',
SoftwareAgent: "PhotoStructure",
When: "2023:10:01 17:13:07.141",
},
],
},
})
expect(t.History).to.be.an("array")
const w = (t.History as any)[0].When
expect(w).to.be.instanceof(ExifDateTime)
expect(w.toString()).to.eql("2023-10-01T17:13:07.141")
})

describe("SubSecDateTimeOriginal", () => {
it("extracts datetimestamp with millis", () => {
const t = parse({
Expand Down
13 changes: 9 additions & 4 deletions src/ReadTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class ReadTask extends ExifToolTask<Tags> {
if (typeof value === "object") {
const result: any = {}
for (const [k, v] of Object.entries(value)) {
result[k] = this.#parseTag(k, v)
result[k] = this.#parseTag(tagName + "." + k, v)
}
return result
}
Expand All @@ -312,12 +312,17 @@ export class ReadTask extends ExifToolTask<Tags> {
// Time-only tags have "time" but not "date" in their name:
const keyIncludesTime = /time/i.test(tagName)
const keyIncludesDate = /date/i.test(tagName)
const keyIncludesWhen = /when/i.test(tagName) // < ResourceEvent.When
const result =
(keyIncludesTime || keyIncludesDate
(keyIncludesTime || keyIncludesDate || keyIncludesWhen
? ExifDateTime.from(value, tz)
: undefined) ??
(keyIncludesTime ? ExifTime.fromEXIF(value) : undefined) ??
(keyIncludesDate ? ExifDate.from(value) : undefined) ??
(keyIncludesTime || keyIncludesWhen
? ExifTime.fromEXIF(value)
: undefined) ??
(keyIncludesDate || keyIncludesWhen
? ExifDate.from(value)
: undefined) ??
value
if (
this.options.backfillTimezones &&
Expand Down

0 comments on commit 9ee6e1f

Please sign in to comment.