Skip to content

Edit Capture Time writes garbage for a capture time it can't fully read, and skips photos without saying so #2505

Closed

Description

@clydecbrown

Problem

shift_iso (crates/catalog/src/dates.rs:46) shifts whatever iso_seconds (crates/catalog/src/stacks.rs:290) can read, and copies the rest of the string into the result without checking it. So a capture time that is only partly readable comes out of Edit Capture Time looking valid, but it's wrong or doesn't read back. Such strings reach the catalog through Lightroom catalog imports, which copy captureTime as it is (crates/engine/src/lightroom_catalog.rs:968).

  • A time that is cut short loses its hour. 2026-01-01T10:0 and 2026-01-01T10 are read as midnight (stacks.rs:298 needs 16 bytes for a time). A one-hour shift writes 2026-01-01T01:00:00.
  • Unreadable seconds become zero. 2026-01-01T10:00:xx reads as 10:00:00 (num(17, 19).unwrap_or(0), stacks.rs:298). The shift writes a clean-looking 11:00:00.
  • Anything after the time is kept as it is. The tail is copied unchecked (dates.rs:53). 2026-01-01T10:00:00+ becomes …T11:00:00+, and 2026-01-01T10:00:00 and more becomes …T11:00:00 and more, which isn't a time.
  • Photos it can't shift are skipped without a word. photo.setCaptureTime drops a photo whose time doesn't read (crates/engine/src/cmd/manage.rs:227-233). Its result, {changed, captured} (manage.rs:253), doesn't say how many were skipped.
  • The preview shows the wrong message. In the dialog's Shift and Time Zone modes, the preview for such a photo says "Enter a date as YYYY-MM-DD HH:MM:SS" (crates/ui-egui/src/panels/dialogs.rs:529), though the user typed no date.

Follows issue #2146, which fixed a time with minutes but no seconds.

Proposed fix

  • shift_iso returns None unless the input is one of:
    • a date alone;
    • a date and a time (T or a space between them) with hours and minutes, optional seconds with an optional fraction (.5), and an optional zone (Z, +02:00, -0500, +02), and nothing after. A fraction after the minutes (10:00.5, half a minute) is refused too: it would come back as half a second.
  • Seconds, when present, must be digits. iso_seconds stays lenient for reading and sorting; only the write path gets stricter.
  • photo.setCaptureTime refuses to set a time for the active photo when that photo's own time can't be read and other selected photos would move by an amount read from it. With that photo alone, or setting every photo's time (each), it gets the time, which repairs it. The dialog shows the refusal and stays open.
  • photo.setCaptureTime counts the photos it skipped because their time doesn't read (unreadable in its result), separately from the "outside 0000–9999" refusal, and the dialog reports them.
  • When the problem is the photo's own time, the dialog preview says the active photo's capture time can't be read, instead of asking for a date.

Acceptance criteria

  • AC-1: shift_iso returns None for 2026-01-01T10:0, 2026-01-01T10, 2026-01-01T, 2026-01-01T10:00:xx, 2026-01-01T10:00:00+, 2026-01-01T10:00:00+2, 2026-01-01T10:00:00. and 2026-01-01T10:00:00 and more, and doesn't panic on multi-byte characters at bytes 11, 16, 18 and 21.
  • AC-2: shift_iso still shifts a date alone, a time with and without seconds, a fraction, and the zones Z, +02:00, -0500 and +02, keeping the fraction and zone; each result reads back through shift_iso(…, 0) unchanged.
  • AC-3: Sorting, grouping and smart-collection date rules still read the strings iso_seconds reads today (no change to iso_seconds's results for existing tests).
  • AC-4: photo.setCaptureTime on two photos, one with a readable time and one with 2026-01-01T10:00:00 and more, shifts the first, leaves the second unchanged, and returns unreadable: 1, in one undo step.
  • AC-5: A photo with a malformed tail isn't counted as "outside the years 0000–9999": that error comes only from a time that reads but would shift out of range.
  • AC-6: In the Edit Capture Time dialog's Shift mode, the preview for an active photo whose time can't be read says so, not "Enter a date as YYYY-MM-DD HH:MM:SS" (UI test in crates/ui-egui/src/tests_<area>.rs).
  • AC-7: Each new test of changed behaviour fails on main before the change.
  • AC-8: Help ▸ What's New has an entry (docs/whats-new.md).
  • AC-9: OK in the Edit Capture Time dialog with such a photo leaves it unchanged, closes the dialog and says that photos whose capture time can't be read were left as they were (UI test).
  • AC-10: photo.setCaptureTime with a time for the active photo (not each) is refused, with an error that says so and no photo changed, when that photo's own capture time can't be read and other selected photos would move by its change. With that photo alone it gets the typed time (repairing it), and with each: true every selected photo gets it, the unreadable one included.
  • AC-11: In the Edit Capture Time dialog's Set mode, the refusal of AC-10 is shown and the dialog stays open; with the unreadable photo alone, the preview shows the time it will get and OK sets it (UI test).
  • AC-12: Any error from photo.setCaptureTime in the Edit Capture Time dialog (a typed time that isn't a date, a shift past year 9999, AC-10's refusal) is shown and the dialog stays open, from its OK button and from the control channel's ui.dialog.confirm alike; before, the dialog closed without a word (UI test).
  • AC-13: The dialog doesn't prefill Set mode with an unreadable capture time (2026-01-01T10:0 would read as midnight); the field starts empty, and with that photo alone the preview asks for a date (UI test).

Activity

  1. ticket-craft commented on Oct 22, 2026

    @ticket-craft

    Thanks! This ticket describes several separate problems:

    • Shifting a capture time that is cut short or has unreadable seconds writes a wrong time
    • Shift keeps a malformed tail after the time, producing an invalid time string
    • setCaptureTime skips unreadable photos without reporting how many
    • Preview says to enter a date when the active photo's time is unreadable

    It helps a lot if each one has its own ticket, so they can be tracked and fixed separately.

  2. mdlmarkham commented on Oct 22, 2026

    @mdlmarkham
    Contributor

    Fixed on #2174 (commit aa77898). What landed:

    • Strict parsing (crates/catalog/src/dates.rs): a capture time must read as a date or it is reported as unreadable; readable_iso says whether a value would survive a shift, shift_iso refuses what it can't read, and out-of-range results (past the years 0000–9999) are refused up front as before.
    • Shift mode (photo.setCaptureTime): photos whose time can't be read are left exactly as they were and counted in the result (unreadable); the readable ones still move. Nothing is written for a photo that would not parse.
    • Set mode: with several photos selected, a partly-readable active time (2026-01-01T10:0) is refused — it would silently become midnight — and the error names the file. With the unreadable photo alone, the typed time is accepted as a repair.
    • Dialog (Edit Capture Time): the preview says why nothing would move ("can't be read" rather than "Enter a date"), a result that left photos untouched toasts how many ("Photos whose capture time can't be read were left as they were: 1"), and errors keep the dialog open — from the OK button and the control channel (ui.dialog.confirm) alike, so the typed choices are not lost.
    • Localised toast in all 13 locales; regression tests in dates.rs, manage.rs/tests_libops.rs and tests_dialogs.rs (preview, prefill, unreadable-left-and-counted, refusal, repair, stay-open on both paths).
  3. added a commit that references this issue on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions