Skip to content

AP-482: Preserve local item times across DST transitions - #30

Open
anarchivist wants to merge 5 commits into
mainfrom
AP-482
Open

anarchivist wants to merge 5 commits into
mainfrom
AP-482

Conversation

@anarchivist

@anarchivist anarchivist commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Build found timestamps from the entered local date and clock time so daylight saving transitions do not shift the saved time.
  • Reject nonexistent Pacific times in the skipped spring hour (for example, March 9, 2025 at 02:30) with a clear form error. Failed creates return HTTP 422, submitted fields remain available for correction, and invalid create or update requests do not save changes.
  • Record a repeated fall-hour time as its first occurrence in Pacific Daylight Time (for example, November 2, 2025 at 01:30 is 08:30 UTC). Explain this rule on both item forms.
  • Standardize CSV import and view specs on the application time zone with Date.current and Time.current. Share Timecop setup for an advancing request clock and a frozen CSV import clock, and wait for the validation result in a staff system spec before checking the page.

Verification

  • Full RSpec suite through Docker Compose: 170 examples, 0 failures.
  • Item request specs through Docker Compose: 21 examples, 0 failures. These cover create and update on both transition dates, skipped spring-hour rejection, and the repeated fall-hour UTC mapping.
  • RuboCop passed.

Time-entry convention

The time field is optional. During the repeated fall hour, the app uses the first occurrence (PDT); the current form does not offer a choice for the second occurrence.

anarchivist and others added 3 commits November 20, 2026 14:07
Build found timestamps from the entered local date and time so daylight saving transitions do not shift the saved clock time. Cover spring and fall create and update flows with shared examples.

Co-authored-by: Codex GPT-6.1-sol <noreply@openai.com>
Use Timecop's block form to restore the clock after each create/update example. Keep travel semantics so time can advance for assertions about updated_at.

Define the normal test time with let and override it in the spring and fall daylight saving contexts. This exercises transition dates in the standard suite and removes the RSPEC_FORCE_DST_FAILURE switch, its helper methods, and the direct TZInfo require. Preserve the fixed UTC expectations for both create and update requests.

Verified through Docker Compose: 16 item request examples and 165 full-suite examples passed; RuboCop passed.

Co-authored-by: Codex GPT-6.1-sol <noreply@openai.com>
Reject local times that do not exist during the spring daylight saving transition before attaching images or saving items. Show a clear error, return HTTP 422 for failed creates, and preserve submitted form values so staff can correct the time. Continue to use the first Pacific Daylight Time occurrence of a repeated fall hour, explain that rule on both item forms, and assert its UTC value for create and update requests.

Use application-zone Date.current and Time.current values in CSV import and view specs. Share Timecop setup through running and frozen RSpec contexts, and pin the CSV import clock for deterministic cutoff tests. Extend the DST shared examples to cover the skipped spring hour and repeated fall hour, including rejection without changing an existing item. Wait for the validation message in the staff system spec before checking the rendered page to avoid a Selenium navigation race.

Verified through Docker Compose: 170 full-suite examples and 21 item request examples passed; RuboCop passed.

Co-authored-by: Codex GPT-6.1-sol <noreply@openai.com>

@awilfox awilfox left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The change is mostly good, and the test cases are very thorough (thanks!), but I have a few items before merge.

Comment thread app/controllers/items_controller.rb Resolved
Comment thread app/controllers/items_controller.rb Resolved
Comment thread app/views/forms/insert_form.html.erb Resolved
Comment thread app/views/items/edit.html.erb Outdated
<%= form.label(:time_found, 'Time found:', class: 'control-label') %>
<%# TODO: figure out why we can't just pass datetime_found %>
<%= form.time_field :time_found, value: @item.datetime_found&.strftime("%T.%L") %>
<%= form.time_field :time_found, value: (params.key?(:time_found) ? params[:time_found] : @item.datetime_found&.strftime("%T.%L")), aria: { describedby: 'time_found_hint' } %>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's a decent hint (and partially solves the documentation question I had above, but I'd still like it documented in the README for devs that may not see this since it's only in edit), but I'm not sure if this is a good describedby on its own.

I'd lean towards this being aria-details, but I'd want an expert's opinion first.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@jxloesberg - any thoughts? (i know you're out next week.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i'm switching this to aria-details in 91db2b3 based on looking at the ARIA attribute documentation. we can certainly fix it in the future.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I agree, aria-details is the way to go here.

@awilfox awilfox left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

r+ pending the ARIA thing. You could take the ARIA markup off and leave the hint itself if you want to merge now, and we can add it in once we have the answer on which one it belongs as. The text is still there for people to read (or have spoken), it's just not fully attached to the element. ("no ARIA is better than bad ARIA")

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.

3 participants