function week() returns wrong value 54 for 27. december 2020

Description

This issue was submitted on the lucee forum at:
https://dev.lucee.org/t/54-weeks-in-2020/7749

e.g. if you run the following code:

The result for variable wrongWeek is 54. Expected value should be 52.

This happens on 5.3.7.47 and below. According to the users post, this issue happens even on Railo Lucee 4.5.5

Environment

None

Activity

Show:
Michael Offner
January 8, 2021, 4:14 PM

please give that build an other try

Pothys - MitrahSoft
January 11, 2021, 6:41 AM

, I've checked this ticket with fixed version 5.3.8.137-SNAPSHOT and the issue was sloved. Now week() return correct result.

could you please check with fixed version.

Andreas R
January 12, 2021, 6:33 PM
Edited

Thanks for notifying and quick fix + PR. and sorry for my delayed reply. Just verified the scripts code. I’m getting week 53 with Lucee 5.3.8.138-SNAPSHOT for all TimeZones.. But(!!!) in my CET Timezone it should be 52 ( {ts '2020-12-27 0:00:00'} is a Sunday and 53 starts on Monday) . Week() of the date {ts '2020-12-27 0:00:00'} in TimeZone “CET” should return 52, not 53. ACF returns correctly 52 for TimeZone CET.

Please see the results with the following code on ACF2021:

https://trycf.com/gist/6e7d5719d43f3d46b721041c950f2150/acf2021?theme=monokai

Ouputs on ACF2021:
Etc/UTC:53
CET:52
PST:53
AGT:53
CST:53
UTC:53

Maybe the fixed function should consider locales. I’ve googled a bit and found the following information:
https://www.baeldung.com/java-get-week-number#3-locale-differences


Zac Spitzer
January 12, 2021, 6:46 PM
KabutoTX
January 12, 2021, 11:13 PM
Edited

It seems Adobe does week by current UTC time of that timezone.

ex. “12/27/2020 0:00:00” with JST timezone set returns 52 on ACF (UTC=”12/26/2020 15:00:00”) . Lucee is assuming the current set time zone.

https://trycf.com/gist/e34d04a340a742492ae7b650709783e3

Assignee

Michael Offner

Reporter

Andreas R

Priority

New

Labels

Fix versions