Format due date with browser locale to match date picker
The read-mode text showed ISO format while the date input used the
browser's locale format. Using toLocaleDateString() on the read-mode
text keeps them consistent. Also dropped "Every" from interval_text
to avoid duplicating the word already in the dt label.
Assisted-by: Claude Opus 4.6 via Claude Code
diff --git a/lib/ketchup/views/home.rb b/lib/ketchup/views/home.rb
index 9b3bb17..683fe9b 100644
--- a/lib/ketchup/views/home.rb
+++ b/lib/ketchup/views/home.rb
@@ -120,7 +120,10 @@ module Views
if @selected_task
dt { "Due date" }
- dd("x-show": "!editing") { @selected_task[:due_date].to_s }
+ dd(
+ "x-show": "!editing",
+ "x-text": "new Date('#{@selected_task[:due_date]}T00:00').toLocaleDateString()"
+ ) { @selected_task[:due_date].to_s }
dd(
"x-show": "editing",
"x-cloak": true,
@@ -318,7 +321,7 @@ module Views
end
def interval_text(count, unit)
- "Every #{count} #{count == 1 ? unit : "#{unit}s"}"
+ "#{count} #{count == 1 ? unit : "#{unit}s"}"
end
end
end
diff --git a/test/test_web.rb b/test/test_web.rb
index 815c458..b76c3b1 100644
--- a/test/test_web.rb
+++ b/test/test_web.rb
@@ -247,7 +247,7 @@ class TestWeb < Minitest::Test
series = DB[:series].first
get "/series/#{series[:id]}", {}, tailscale_headers
assert last_response.ok?
- assert_includes last_response.body, "Every 2 weeks"
+ assert_includes last_response.body, "2 weeks"
assert_includes last_response.body, "2026-03-01"
assert_includes last_response.body, "task-selected"
end