Skip to content

Add camera clock correction to photo imports - #14

Merged
nedcut merged 2 commits into
mainfrom
codex/reconcile-photo-timezones
Jul 11, 2026
Merged

Add camera clock correction to photo imports#14
nedcut merged 2 commits into
mainfrom
codex/reconcile-photo-timezones

Conversation

@nedcut

@nedcut nedcut commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • honor embedded EXIF timezone offsets, including iPhone OffsetTimeOriginal
  • interpret timezone-less capture times in the trip timezone instead of the uploader's browser timezone
  • add a batch camera-clock correction control for timezone-less photos and videos
  • recompute automatic day matching and inferred placement after a clock correction while preserving GPS and manual pins

Why

Digital cameras commonly store a local wall-clock capture time without a timezone. The importer previously parsed that value in the uploader's browser timezone, so photos taken at the same moment could appear hours apart from iPhone photos. Some cameras also have an incorrectly set clock, which requires an explicit batch adjustment even after applying the trip timezone.

The new control is intentionally scoped only to items without embedded timezone metadata. Mixed iPhone/camera batches therefore preserve authoritative iPhone instants while allowing camera timestamps to be shifted by a whole-hour offset with an immediate preview in the import queue.

Changing the correction replaces the prior value rather than compounding it. If the adjusted timestamp crosses midnight, day matching is recalculated. Time- and route-inferred positions are rebuilt from the corrected timestamp; EXIF GPS and user-placed pins remain unchanged.

Validation

  • npm run ci — 207 tests passed; typecheck passed; lint passed with one pre-existing useMembership.ts warning
  • npm run build — production build passed
  • npm run test:e2e — 7 Playwright tests passed across desktop and mobile
  • git diff --check

Scope note

The previously approved one-off production correction for the existing 40-camera-photo batch was performed separately. This PR contains no data migration and does not repeat that update.

Summary by CodeRabbit

  • New Features

    • Added camera clock correction controls during photo placement.
    • Users can adjust timestamps by hour for eligible photos, with changes reflected in placement and trip dates.
    • Supports camera timezone offsets and improved EXIF timestamp interpretation.
  • Bug Fixes

    • Prevents corrections from compounding and preserves timestamps that already include timezone information.
    • Improved handling of midnight crossings and invalid date values.

@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lofoten-map Ready Ready Preview, Comment Jul 11, 2026 6:42pm

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b4e459b5-42cc-4a2e-b72a-ad57893a4901

📥 Commits

Reviewing files that changed from the base of the PR and between ed21685 and 809486c.

📒 Files selected for processing (5)
  • components/PlacementWorkspace.tsx
  • components/UploadPhotoPanel.tsx
  • lib/exif.test.ts
  • lib/exif.ts
  • lib/upload-queue.ts

📝 Walkthrough

Walkthrough

Camera EXIF parsing now records timezone provenance and supports camera clock correction. Upload analysis applies and reapplies corrections before placement, while PlacementWorkspace exposes the setting on desktop and mobile.

Changes

Camera clock correction

Layer / File(s) Summary
EXIF timezone parsing and correction
lib/exif.ts, lib/exif.test.ts
EXIF timestamps now support offsets, identify embedded or trip-local timezones, and apply non-compounding clock corrections with updated dates.
Upload placement integration
components/UploadPhotoPanel.tsx, lib/upload-queue.ts
Upload analysis applies the selected correction before automatic placement, supports recalculation, restores and resets correction state, and preserves analyzed item subtypes.
Workspace camera control
components/PlacementWorkspace.tsx
The workspace renders a conditional hour-offset selector in desktop and mobile layouts, disabling it during saving or active reading operations.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant UploadPhotoPanel
  participant EXIF
  participant PlacementWorkspace
  participant PlacementQueue
  UploadPhotoPanel->>EXIF: Extract and correct photo timestamps
  UploadPhotoPanel->>PlacementQueue: Run automatic placement
  UploadPhotoPanel->>PlacementWorkspace: Pass correction state and callback
  PlacementWorkspace->>UploadPhotoPanel: Submit selected hour offset
  UploadPhotoPanel->>EXIF: Recalculate corrected timestamps
  UploadPhotoPanel->>PlacementQueue: Recompute automatic placement
Loading

Possibly related PRs

  • nedcut/lofoten-map#6: Introduced the PlacementWorkspace and UploadPhotoPanel flow extended by this camera-clock correction change.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding camera clock correction during photo imports.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/reconcile-photo-timezones

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nedcut
nedcut marked this pull request as ready for review July 11, 2026 18:20
Copilot AI review requested due to automatic review settings July 11, 2026 18:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

- Pad seconds-less datetimes before building the ISO string so an
  explicit offset is not silently discarded as an invalid Date
- Honor a zone designator trailing the datetime value itself (video
  creation times like ...T14:30:00Z) instead of reinterpreting the
  instant as trip-local wall clock and leaving it user-shiftable
- Accept colon-less offsets (+0200) from cameras
- Derive timeZoneSource in parseExifDate rather than re-matching the
  offset tag in extractPhotoExif, which mislabeled fallback parses
- Restore the camera clock correction select state when restoring a
  draft whose items already carry a correction
@nedcut
nedcut merged commit bd21259 into main Jul 11, 2026
4 checks passed
@nedcut
nedcut deleted the codex/reconcile-photo-timezones branch July 11, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants