Closing time in local time for users without a time zone

Users without a time zone in their preferences fell back to UTC, so a 17:00 closing time stopped their
timers hours early (e.g. at noon on a US Eastern server). Like Redmine (User#today), they now get the
server's local time: for closing time, the Running timers page's "stopped at" field, and the "Timer
stopped by" note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-02 18:07:44 -05:00
1 parent 82ffe7ed49
commit 9c937c6d6b
7 files changed
+41 -15

No files matched your search

+9 -4
View File
@@ -61,14 +61,19 @@ module Stopwatch
hour < 24 && minute < 60 ? [hour, minute] : nil
end
# Closing time on the day of the given time, in the user's time zone, or nil when no stop time is set
# Closing time on the day of the given time, in the user's time zone, or nil when no stop time is set.
# A user without a time zone gets the server's local time, as Redmine does (User#today), not UTC.
def self.closing_time_on(time, user)
hour, minute = stop_time
return nil unless hour
zone = user.time_zone || Time.zone
day = time.in_time_zone(zone)
zone.local(day.year, day.month, day.day, hour, minute)
if (zone = user.time_zone)
day = time.in_time_zone(zone)
zone.local(day.year, day.month, day.day, hour, minute)
else
day = time.getlocal
Time.local(day.year, day.month, day.day, hour, minute)
end
end
# Colour-code the issue Start/Stop links (green to start, red to stop)