Skip to main content
manfjon67
Participant
January 21, 2021
Question

Week() function

  • January 21, 2021
  • 2 replies
  • 487 views

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)?

This topic has been closed for replies.

2 replies

Charlie Arehart
Community Expert
Community Expert
January 26, 2021

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. 

/Charlie (troubleshooter, carehart. org)
BKBK
Community Expert
Community Expert
January 21, 2021

Indeed, that doesn't look good. The week number is more or less universal. You might want to report a bug.

manfjon67
manfjon67Author
Participant
January 26, 2021

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)

Charlie Arehart
Community Expert
Community Expert
January 26, 2021

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. 

/Charlie (troubleshooter, carehart. org)