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

format_date() function converts date to user timezone regardless $convert=false #9666

Open
2 tasks done
metalefty opened this issue Oct 8, 2024 · 1 comment
Open
2 tasks done
Labels

Comments

@metalefty
Copy link

Prerequisites

  • I have searched for duplicate or closed issues
  • I can recreate the issue with all plugins disabled

Describe the issue

Here's the background
#7352 (comment)

Expected behaviour:
format_date() does not convert the timezone of the given date.

format_date('Tue, 8 Oct 2024 07:12:23 +0000', 'u', false); # => 2024-10-08T16:12:23+09:00

Actual behaviour:
format_date() always converts the timezone of the given date to user timezone.

format_date('Tue, 8 Oct 2024 07:12:23 +0000', 'u', false); # => 2024-10-08T07:12:23+00:00

What browser(s) are you seeing the problem on?

Chrome, Edge, Firefox, Safari, Other

What version of PHP are you using?

8.1.29

What version of Roundcube are you using?

1.6.9

JavaScript errors

No response

PHP errors

No response

@pabzm pabzm added the bug label Oct 16, 2024
@pabzm
Copy link
Member

pabzm commented Oct 23, 2024

I don't quite understand you examples: what you show as "expected" behaviour does change the timezone, doesn't it? Did you accidentally swap the two code lines?
(Also the $format 'u' should be 'c' I think.)

Regardless I can confirm that the $convert argument doesn't do what it claims.

It is called from core code only in program/actions/contacts/index.php:1353, and additionally in the plugin 'managesieve' (several times in plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php). So I guess the danger to break important things is rather low.
Unfortunately we don't have any tests for that method yet.

@metalefty Do you by chance feel competent to propose a fix? Also starting one and asking for help if you get stuck would be helping a lot already. I guess not converting the input into timestamps and maybe starting to use IntlDateFormatter would be good first steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants