Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: First try at parsing the timezone information for the sony A7 camera #188

Merged
merged 2 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Timezones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,15 +426,16 @@
export function extractTzOffsetFromUTCOffset(
t: Pick<
Tags,
| (typeof CapturedAtTagNames)[number]

Check failure on line 429 in src/Timezones.ts

View workflow job for this annotation

GitHub Actions / lint

Type '"GPSDateTime" | "SubSecCreateDate" | "SubSecDateTimeOriginal" | "SubSecMediaCreateDate" | "CreateDate" | "DateTimeOriginal" | "GPSDateStamp" | "GPSTimeStamp" | "DateTimeCreated" | ... 4 more ... | "SonyDateTime2"' does not satisfy the constraint 'keyof Tags'.
| "GPSDateTime"
| "DateTimeUTC"
| "GPSDateStamp"
| "GPSTimeStamp"
| "SonyDateTime2"
>
): Maybe<TzSrc> {
const utcSources = {
...pick(t, "GPSDateTime", "DateTimeUTC"),
...pick(t, "GPSDateTime", "DateTimeUTC", "SonyDateTime2"),
GPSDateTimeStamp: map2(
blankToNull(t.GPSDateStamp), // Example: "2022:04:13"
blankToNull(t.GPSTimeStamp), // Example: "23:59:41.001"
Expand All @@ -444,10 +445,10 @@

// We can always assume these are in UTC:
const utc = first(
["GPSDateTime", "DateTimeUTC", "GPSDateTimeStamp"] as const,
["GPSDateTime", "DateTimeUTC", "GPSDateTimeStamp", "SonyDateTime2"] as const,
(tagName) => {
const v = utcSources[tagName]
const edt = v instanceof ExifDateTime ? v : ExifDateTime.fromExifStrict(v)

Check failure on line 451 in src/Timezones.ts

View workflow job for this annotation

GitHub Actions / lint

Argument of type 'unknown' is not assignable to parameter of type 'Maybe<string>'.
const s =
edt != null && (edt.zone == null || isUTC(edt.zone))
? edt.setZone("UTC", { keepLocalTime: true })?.toEpochSeconds()
Expand Down
1 change: 1 addition & 0 deletions src/update/mktags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ const RequiredTags: Record<string, { t: string; grp: string; value?: any }> = {
ShutterCount2: { t: "number", grp: "MakerNotes" },
ShutterCount3: { t: "number", grp: "MakerNotes" },
ShutterSpeed: { t: "string", grp: "Composite" },
SonyDateTime2: { t: "ExifDateTime | string", grp: "MakerNotes" },
SonyExposureTime: { t: "string", grp: "MakerNotes" },
SonyFNumber: { t: "number", grp: "MakerNotes" },
SonyISO: { t: "number", grp: "MakerNotes" },
Expand Down
Loading