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:

<cfscript> this_week = Week(now()); wrongWeek=Week("{ts '2020-12-27 0:00:00'}") writedump(this_week); writedump(wrongWeek); </cfscript>

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

Attachments

1

Activity

Michael Offner 
12 April 2021 at 10:29

Week and LSWeek use the same underlaying function, week simply set “Locale.USfor locale and lsWeek uses the week defined with locale, so there is nothing need to be done with lsweek.

Michael Offner 
12 April 2021 at 10:20

do we need a ticket for lsWeek as well?

KabutoTX 
12 January 2021 at 23:13
(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

Zac Spitzer 
12 January 2021 at 18:46

Andreas R 
12 January 2021 at 18:33
(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

<cfscript> cfloop(list="current,CET,PST,AGT,CST,UTC", item="tz") { if (tz neq "current"){ SetTimeZone(tz); } writeDump(getTimeZone()); writeDump( Week("{ts '2020-12-27 0:00:00'}")); writeoutput("<hr>"); } </cfscript>

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


Fixed

Details

Assignee

Reporter

Priority

Labels

Fix versions

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Created 28 December 2020 at 01:55
Updated 12 April 2021 at 10:29
Resolved 12 April 2021 at 10:19