Copy link to clipboard
Copied
At one of our customers we’re migrating an old CFMX7 application to CF2021. In certain reports the Week() function is used.
<cfset oldlocale = SetLocale (“Dutch (Standard)”)>
We’re performing the initial tests in our CF2018 developer environment. In using Week() in CFMX7 the week starts at Mondays and weeknumbers are correct. Using the same source code in CF2018 the week suddenly starts at Sundays and weeknumbers are incorrect (for instance today – 21/01/2021 – returns week 4 instead of week 3).
What could be the cause for this? Or is there some kind of setting we’re missing (I checked cfadmin, but couldn’t find a lead)?
Copy link to clipboard
Copied
Indeed, that doesn't look good. The week number is more or less universal. You might want to report a bug.
Copy link to clipboard
Copied
I reported the bug as per https://tracker.adobe.com/#/view/CF-4211043. Does anyone know how long it normally takes before Adobe provides a first response to an issued bug report?
(I tried to get an answer from Adobe Customer Care, but they say they cannot answer this question and referred back to this forum)
Copy link to clipboard
Copied
Separate from my first reply here, to this question I'll say it could be hours, weeks, never or in between. There's just no typical time I've seen.
There also no guarantee of a reply, which is sad, though often at least some response will come eventually. It does seem that the more succinct and/or easily replicable the report is, the greater the chances of a response.
Again, though, I suspect this issue above is not a bug. See my longer reply here.
Copy link to clipboard
Copied
@manfjon67 , thanks for the update. I have voted to have the bug fixed, and included the following comments:
Hi Manfred D., There is documented support for your claim that this is a bug. According to the International Standards on dates, ISO 8601, Friday 22-1-2021, Saturday 23-1-2021 and Sunday 24-1-2021 have week-number 3, whereas Monday 25-1-2021 and Tuesday 26-1-2021 have week-number 4. Exactly as you expected. See https://en.wikipedia.org/wiki/ISO_8601
The moral here is that ColdFusion should base its definition of datetime functions on standards that are widely agreed upon.
Copy link to clipboard
Copied
Did either of you consider what I wrote below? It's not a bug if this is instead simply a problem of what JVM settings (whether provided or not provided) are influencing the behavior. If either you have confirmed that's NOT the answer, can you offer it here, wherther as a reply to this or my comment below?
Copy link to clipboard
Copied
At this moment I'm still considering both scenario's. I'm investigating the JVM settings (Djava.locale.providers - Oracle's documentation for the first day of the week, "SUNDAY in the U.S., MONDAY in France") on the 3 different platforms (hosted in the UK and in The Netherlands) that I use to do the comparisons. That might solve the issue for the starting date of the week, but I'm not sure it will also solve the issue of the weeknumber being 1 too high.
Copy link to clipboard
Copied
Our hosting provider in the UK made changes to the JVM arguments. The Java Default Locale has been set to nl_NL, but unfortunately this didn't have any effect on the Week() function.
For the DayOfWeek() function Adobe decided to add the optional 'calender' parameter as per CF2018 Update 2. I added this function to our earlier testroutine with the following results:
vr 22-01-2021, weeknr 4 / 2021, DayOfWeek std: 6, DayOfWeek gregorian: 6, DayOfWeek iso: 5
za 23-01-2021, weeknr 4 / 2021, DayOfWeek std: 7, DayOfWeek gregorian: 7, DayOfWeek iso: 6
zo 24-01-2021, weeknr 5 / 2021, DayOfWeek std: 1, DayOfWeek gregorian: 1, DayOfWeek iso: 7
ma 25-01-2021, weeknr 5 / 2021, DayOfWeek std: 2, DayOfWeek gregorian: 2, DayOfWeek iso: 1
di 26-01-2021, weeknr 5 / 2021, DayOfWeek std: 3, DayOfWeek gregorian: 3, DayOfWeek iso: 2
When setting calender to "iso" in this function the results are as they should be in our region (week starts at Mondays).
Does any of the Adobe Community Professionals know why Adobe decided not to add the same optional parameter to the Week() function??
Copy link to clipboard
Copied
Manfjon67, I would not expect this to be a change caused by newer cf versions (let alone a bug, your current assumption). Instead, I suspect this is more about a difference at the Java level between your cf7 and cf2018, or perhaps the os level if they are on different machines.
First, let me say also that the setlocale you're doing would only have affected locale-specific functions, like lsdateformat vs dateformat. There's none for week(). (And some functions take a locale as an arg, but week does not, though dayofweek does.)
So instead in your case again I expect this is caused by and can be fixed by jvm or os settings instead. As you may know, since cf6 cf runs atop Java. And java version differences or Java settings can account for what seem differences between one cf implementation and another.
In this case, the day of week calculations are indeed affected by Java, as discussed in places like this: https://www.oracle.com/technical-resources/articles/javase/locale.html
That discusses locale (country or region) settings, which can be set as system properties the jvm startup args. In cf, those can be set or changed in the cf admin "Java and jvm" page or the corresponding jvm.config file that updates.
You should assess that Java args line there, on your cf7 and cf2018, to see what values if any are there, and to consider changing the 2018 one to be similar to the cf7 one. Or if the 7 one had none, certainly that was a much older jvm so may have had different defaults. (Or the OS on which it was installed may have had different defaults, which the jvm inherited.)
Btw, if these two cf instances where on the same machine, one could wonder, "couldn't they both be using the same jvm"? Not by default, as each cf instance implements it's own jvm. And regardless, each cf instance sets its own jvm args affecting its startup.)
Let us know if this gets you going. I'm writing from my phone and can't test/prove it, but wanted to give you something to try.