dateConvert() conundrum; die in a fire or continued support

The following code works fine in 4.5 and ACF:

<cfset utcNow = dateConvert("local2UTC", now())>

But in Lucee 5 i get this helpful advice:

This function is no longer supported, because it gives you the wrong impression that the timezone
 is part of the date object, what is wrong!When you wanna convert a Date to String based on the 
UTC timezone, do for example [DateTimeFormat(date:now(),timezone:'UTC')].

Presumably this is an ACF incompatibility… what should i do here? Raise an issue for Velvet? Or was there a specific reason for introducing this change?

@micstriit responds:

This function is terrible because it does not was is described, every use of this function is misleading, but we can remove this restriction and reenable it… I will raise this with tag

My only issue is that it breaks ACF compatibility. What would i use instead that works on both ACF and Lucee 5?

@micstriit ripostes:

Point is, when you use this function something with your code is wrong. A timezone is for a date nothing other than a locale, a locale influence how a date looks like when you output it.

So for example 5.6.12 for de-ch
But 6/5/12 for en-us

But the date is still the same and most important the date object is independent from any locale same for timezone

So you cannot convert a date from being local to being UTC.
So there is no replacement for invalid code.
Question is how to fix this code.

This is all well and good, but I am a humble CFML developer. What can I do to replace this code with something that works with both Lucee 5 and ACF?

<cfset utcNow = dateConvert("local2UTC", now())>
<cfset utcDateTime = dateFormat(utcNow, "yyyy-mm-dd") & " " & timeFormat(utcNow, "hh:mm:ss") & " +0000">

Or am I better off just ripping this out of my code base and replacing it with something less “terrible” :wink: If I do this what about all the other poor chumps using this function?

If it’s not deprecated in ACF then it should probably continue to work in Lucee 5 (for .cfm and .cfc files) as it did in Lucee 4.5.

@micstriit has very valid points, it’s a terrible function.

But for ACF compatibility is really has tostay in Lucee 5 (non LuceeLang) imho.

@modius, ping Brad if you think this warrants a TAG discussion (there’s a meeting on early Wed AU time), but my tendency would be to make sure it’s in Lucee 5 again.

The decision to remove this function was made before we decided to be more compatible with ACF as before because we now have the Lucee dialect, removing this function sends the wrong message, so in my opinon we should add it again.
So +1 to add it again.

1 Like