Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/56771 meeting timestamp in edit form not the same as in details #16567

Merged

Conversation

ulferts
Copy link
Contributor

@ulferts ulferts commented Aug 30, 2024

Ticket

https://community.openproject.org/wp/56771

What are you trying to accomplish?

The PR ensures that times and time zones displayed in the meetings module are always in the time zone of the current user. The bug originally reported in the work package could not be reproduced but before, different code paths have been used for rendering the time zone and the calculation on times was in part achieved by setting the request's time to be in the current user's time.

What approach did you choose and why?

  • Querying for User.current.time_zone will now always return a value. It will never be nil. Either the time zone selected by the user or the time zone set as the default (Setting.user_default_timezone) is returned. This already used to be the case for logged in users. For those, in case no default is set, UTC is now returned. Internally, it was already handled as such as both server and database are running on UTC. The internal users (e.g. AnonymousUser) follow the same pattern.
  • The i18n helpers for format_time and format_date_as_time have been simplified. There used to be code in there that was working with the localtime. Since a few rails versions back, the server is always running in UTC so there is no need for this code. The only times now necessary are UTC and the user's local time. The server's local time should have no effect. Those methods get their signature updated to use named parameters.
  • formatted_time_zone_offset is added to I18n which will give the currently active time offset to the user's time zone compared to UTC. This is now employed throughout the meeting module.
  • Because time/date calculations are now handled at the places that matter, the before action that changed the request's time zone is no longer necessary and is thus removed.
  • The user settings time zone select field has it's blank value removed. This is in line with the user always having UTC as their fallback timezone. Along the same line of thinking it would make sense to remove the blank value from the Setting.user_default_timezone select and set the value to UTC as a default but this is not done in the scope of this PR.

Merge checklist

  • Added/updated tests

@ulferts ulferts force-pushed the bug/56771-meeting-timestamp-in-edit-form-not-the-same-as-in-details branch from c234011 to 4c61ce1 Compare September 6, 2024 08:16
@ulferts
Copy link
Contributor Author

ulferts commented Sep 6, 2024

Rubocop is complaining about the complexity of a method touched within the PR. The PR only changes the call signature of a method called from within the complained about method. Therefore, I deem it ok to not improve that method.

@ulferts ulferts marked this pull request as ready for review September 6, 2024 12:52
Copy link
Member

@cbliard cbliard left a comment

Choose a reason for hiding this comment

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

Really nice refactoring 👏 It simplifies the code dealing with time zones and removes a lot of useless code which is always a good sign.

I only have some minor improvement suggestions.
Feel free to merge whenever you see fit.

For that long method rubocop is complaining about, if it's ok to keep it, then it could be # rubocop:disable Metrics/AbcSize.

app/models/user.rb Show resolved Hide resolved
app/models/anonymous_user.rb Outdated Show resolved Hide resolved
app/views/users/_preferences.html.erb Outdated Show resolved Hide resolved
lib_static/redmine/i18n.rb Show resolved Hide resolved
lib_static/redmine/i18n.rb Show resolved Hide resolved
lib_static/redmine/i18n.rb Show resolved Hide resolved
spec/lib/redmine/i18n_spec.rb Show resolved Hide resolved
@ulferts ulferts force-pushed the bug/56771-meeting-timestamp-in-edit-form-not-the-same-as-in-details branch from 2055cf1 to ecf9b90 Compare September 24, 2024 12:21
@ulferts ulferts force-pushed the bug/56771-meeting-timestamp-in-edit-form-not-the-same-as-in-details branch from ecf9b90 to cd615f5 Compare September 24, 2024 12:26
@ulferts
Copy link
Contributor Author

ulferts commented Sep 24, 2024

I'll merge this one in after the release branch for 14.6 has been created.

@EinLama
Copy link
Contributor

EinLama commented Sep 26, 2024

The release branch for 14.6 has been created 👍🏻

@ulferts ulferts merged commit 048e728 into dev Sep 26, 2024
10 of 11 checks passed
@ulferts ulferts deleted the bug/56771-meeting-timestamp-in-edit-form-not-the-same-as-in-details branch September 26, 2024 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants