Timezone-aware completion timestamps and location-based time handling #183

Closed
opened 2026-06-09 01:36:32 +00:00 by ldraney · 0 comments
Owner

Type

Feature

Lineage

Standalone — discovered during daily use. Completion times need to reflect the crew's actual location, not a hardcoded server timezone.

Repo

ldraney/landscaping-assistant

User Story

As a crew member
I want to see what time I finished each property in my local timezone
So that I can track my pace and review my day accurately

Context

The app hardcodes config.time_zone = "Mountain Time (US & Canada)" and has no concept of per-property or per-user timezone. When a work queue item is checked off, no timestamp is recorded — just a boolean toggle. The crew operates from their phones at property locations, so the browser knows the correct timezone via Intl.DateTimeFormat. Properties already have lat/lng but the GPS detection JS never sends them to the server, and no timezone is derived from location.

File Targets

Files to modify:

  • app/controllers/application_controller.rb -- browser timezone cookie → Time.zone per request
  • app/controllers/work_queue_items_controller.rb -- use toggle_completion! to set completed_at
  • app/controllers/properties_controller.rb -- permit time_zone param
  • app/models/property.rb -- local_time_zone helper
  • app/models/work_queue_item.rb -- toggle_completion!, finished_at_local
  • app/views/work_queue_items/_queue_item.html.erb -- show "Finished at" time
  • app/views/layouts/application.html.erb -- browser_tz cookie script
  • app/javascript/controllers/add_location_controller.js -- send lat/lng + timezone
  • bin/dev -- fix to use docker compose
  • db/migrate/ -- new migration for completed_at and time_zone columns

Feature Flag

none — this is a core data model improvement, not a toggleable workflow.

Acceptance Criteria

  • When I check off a property, I see "Finished at 2:34 PM" in my local timezone
  • When I uncheck it, the address line returns
  • When I detect GPS on a property page, lat/lng and timezone are saved
  • When I open the app from a non-Mountain timezone, "Today" reflects my local date

Test Expectations

  • Model spec: toggle_completion! sets/clears completed_at
  • Model spec: finished_at_local returns time in property timezone
  • Request spec: PATCH /today/:id sets completed_at
  • Run command: bundle exec rspec spec/models/work_queue_item_spec.rb spec/requests/work_queue_items_spec.rb

Constraints

  • No new gems — timezone detection uses browser Intl API
  • Must work in Docker (gems not installed locally)
  • Property timezone falls back to app default when not set

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • landscaping-assistant -- project this affects
### Type Feature ### Lineage Standalone — discovered during daily use. Completion times need to reflect the crew's actual location, not a hardcoded server timezone. ### Repo `ldraney/landscaping-assistant` ### User Story As a crew member I want to see what time I finished each property in my local timezone So that I can track my pace and review my day accurately ### Context The app hardcodes `config.time_zone = "Mountain Time (US & Canada)"` and has no concept of per-property or per-user timezone. When a work queue item is checked off, no timestamp is recorded — just a boolean toggle. The crew operates from their phones at property locations, so the browser knows the correct timezone via `Intl.DateTimeFormat`. Properties already have lat/lng but the GPS detection JS never sends them to the server, and no timezone is derived from location. ### File Targets Files to modify: - `app/controllers/application_controller.rb` -- browser timezone cookie → Time.zone per request - `app/controllers/work_queue_items_controller.rb` -- use toggle_completion! to set completed_at - `app/controllers/properties_controller.rb` -- permit time_zone param - `app/models/property.rb` -- local_time_zone helper - `app/models/work_queue_item.rb` -- toggle_completion!, finished_at_local - `app/views/work_queue_items/_queue_item.html.erb` -- show "Finished at" time - `app/views/layouts/application.html.erb` -- browser_tz cookie script - `app/javascript/controllers/add_location_controller.js` -- send lat/lng + timezone - `bin/dev` -- fix to use docker compose - `db/migrate/` -- new migration for completed_at and time_zone columns ### Feature Flag none — this is a core data model improvement, not a toggleable workflow. ### Acceptance Criteria - [ ] When I check off a property, I see "Finished at 2:34 PM" in my local timezone - [ ] When I uncheck it, the address line returns - [ ] When I detect GPS on a property page, lat/lng and timezone are saved - [ ] When I open the app from a non-Mountain timezone, "Today" reflects my local date ### Test Expectations - [ ] Model spec: toggle_completion! sets/clears completed_at - [ ] Model spec: finished_at_local returns time in property timezone - [ ] Request spec: PATCH /today/:id sets completed_at - Run command: `bundle exec rspec spec/models/work_queue_item_spec.rb spec/requests/work_queue_items_spec.rb` ### Constraints - No new gems — timezone detection uses browser Intl API - Must work in Docker (gems not installed locally) - Property timezone falls back to app default when not set ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `landscaping-assistant` -- project this affects
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ldraney/landscaping-assistant#183
No description provided.