Skip to content

bug #14769 : The start hour and the end Hour are now well processed #895

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

Merged
merged 3 commits into from
Apr 9, 2025

Conversation

SilverDav
Copy link
Contributor

No description provided.

@mmoqui mmoqui self-assigned this Mar 31, 2025
Copy link
Member

@mmoqui mmoqui left a comment

Choose a reason for hiding this comment

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

The current code is problematic because LocalDateTime is used. LocalDateTime is built from the timezone of the server. But the date time that is passed by the form is in the timezone of the user who filled the form. The two timezones can be the same (the one of the server and the one of the user) but such assumptions should be avoided and the timezone of the user has to be taken. Snippet of code to get the correct zone id:

User requester = User.getCurrentRequester();
ZoneId zoneId;
if (requester != null) {
  zoneId = requester.getUserPreferences().getZoneId();
} else {
  zoneId = ZoneId.systemDefault();
}
...
if (StringUtil.isValidHour(startHourValue)) {
  var localDateTime = LocalDateTime.parse(startDayValue + " " + startHourValue, DATE_TIME_FORMATTER);
  var offset = ZoneId.systemDefault().getRules().getOffset(localDateTime.atZone(zoneId).toInstant());
  start = localDateTime.atOffset(offset);
}
...

Copy link

sonarqubecloud bot commented Apr 4, 2025

@mmoqui mmoqui merged commit b417fed into Silverpeas:6.4.x Apr 9, 2025
3 checks passed
@SilverDav SilverDav deleted the bug-14769 branch July 1, 2025 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants