i have a question, as we are migrating the code to...
# cfml-general
s
i have a question, as we are migrating the code to 2021, the date which DD has issues in cfml, can we do something like a custom udf or any javacode in application.cfm or cfc which will take care of the date everywhere as we have tons of file which might need a change and some are really complicated
r
@carehart has a blog entry on this at https://www.carehart.org/blog/2020/11/24/breaking_change_in_cf2021_dateformat_D_vs_d and another one linked from there that may be helpful.
(It's the second Google search result for "adobe coldfusion 2021 dateformat mask DD")
I will also add that we went the route of reviewing and updating our relatively large codebase to address this rather than relying on potentially broken code and/or a JVM argument to change behavior. Felt safer in the long run, and it was helped by not having a huge number of hard-coded format masks sprinkled through the code (with the exception of some relatively old code, most of our format masks are kept as part of the application configuration for consistency).
1
c
Thanks for the mention, Ryan. BTW, as for your effort to update the CFML code instead (and in case others consider that), note that in my post I have a section, "_Some regex's to more easily find occurrences of this D in dateformat expressions_", where I point to comments from @Scott Steinbeck and Curtis Fraser who kindly offered ones for different editors. I realize it's possible you did all your searching and changing before those were offered in Dec 2020 and Apr 2021.
👍🏻 1
s
I thought this was turned into an optional setting for cf2021, was it not?
c
Scott, this problem only affects CF2021. It started then, and the post was from right after its release in Nov 2020. What you may be recalling is that at first they had a hotfix allowing the JVM arg (and I did another post about that). Then in update 1 one no longer needed to use that hotfix (to USE the JVM arg) but the arg was still required (if one wanted to revert CF the old pre-2021 behavior), and I did another post then about that. So the jvm arg is indeed "optional" still, for those not affected by the problem, or who change their CFML instead.
s
oh i thought you had to enable the new date mask, not disable it
c
it's understandable that now over 18 months on, it's easy to lose track. But are you saying now you understand things, with my last reply? Or are you still asking where things stand?
s
yes, i understand.
I just assumed, when they “fixed” the problem, they made the new functionality an optional feature, since i gathered that the cons outweighed the pros for teams upgrading to 2021
c
OK. And for anyone else: the datemask problem (the change in how D is interpreted) did START with CF2021. And what's OPTIONAL now is to add the jvm arg to REVERT it to the pre-2021 behavior. To be clear, update 1 did not itself revert the behavior (as some thought). Or you can use Scott's and Curtis's awesome regex's to find and change your datemask D values to d, instead.
s
for reference here is the VS Code search regex i posted in the ticket
Copy code
Here is the regex:
l?s?(dateformat|datetimeformat)(.*?)[''"](.*?)[DY]{1,10}(.*?)[''")]

Pattern Breakdown:
- l?s?(dateformat|datetimeformat) --> find lsdateformat, lsdatetimeformat, dateformat, datetimeformat
- (.*?)[''"] --> lazy search until you find a single or double quote
- (.*?)[DY]{1,10} --> lazy search until you can find a string containing between 1 - 10 characters of D and or Y
- (.*?)[''")] --> lazy search until you find a single or double quote or a ending parenthesis
c
Ah, ok. That's a bit different from the one you'd offered in the comment there (on my post) in Dec 2020. I have just added a comment noting that (and of course crediting you), for those who may still find that post and not this discussion or that ticket. Thanks for your efforts there.
s
Oh that is the one i posted to the Adobe tracker, I didn’t realize the regex was different. let me check
ah, they are almost equivalent, I added an ending parenthesis to the regex in case you were using a variable name instead of a string as your mask
c
Ok, so you're confirming that that one you shared here is for now the best one so far, right? :-)
s
Correct!
👍 1