mirror of
https://github.com/rickbarrette/stopwatch.git
synced 2026-11-17 19:50:36 -05:00
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:
1 parent
82ffe7ed49
commit
9c937c6d6b
7 files changed
+41
-15
No files matched your search
@@ -40,9 +40,11 @@ class StopwatchRunningTimersController < StopwatchController
|
||||
User.current.allowed_to?(:view_running_timers, nil, global: true) or deny_access
|
||||
end
|
||||
|
||||
# The "stopped at" field is a local date and time in the viewer's time zone
|
||||
# The "stopped at" field is a local date and time in the viewer's time zone, or the server's local time for
|
||||
# a viewer without one (as Redmine shows times)
|
||||
def parse_user_time(value)
|
||||
(User.current.time_zone || Time.zone).parse(value.to_s)
|
||||
zone = User.current.time_zone
|
||||
zone ? zone.parse(value.to_s) : Time.parse(value.to_s)
|
||||
rescue ArgumentError
|
||||
nil
|
||||
end
|
||||
|
||||
@@ -45,8 +45,8 @@
|
||||
<% if row.started_at %>
|
||||
<%# Optional: when the person actually stopped working; blank = now %>
|
||||
<%= datetime_local_field_tag :stopped_at, nil,
|
||||
min: row.started_at.in_time_zone(User.current.time_zone || Time.zone).strftime('%Y-%m-%dT%H:%M'),
|
||||
max: Time.now.in_time_zone(User.current.time_zone || Time.zone).strftime('%Y-%m-%dT%H:%M'),
|
||||
min: User.current.convert_time_to_user_timezone(row.started_at).strftime('%Y-%m-%dT%H:%M'),
|
||||
max: User.current.convert_time_to_user_timezone(Time.now).strftime('%Y-%m-%dT%H:%M'),
|
||||
title: l(:text_stopwatch_stopped_at), 'aria-label': l(:label_stopwatch_stopped_at),
|
||||
id: "stopped_at_#{row.user.id}" %>
|
||||
<% end %>
|
||||
|
||||
Reference in new issue
Block a user