Whenever you want to compare date or time elements, then make sure you are not comparing strings, but instead are comparing number or date objects.
Your current code does a string comparison “06:45 PM” lt “07:50 AM”, which indeed is true. Lucee is correct.
The reason ACF did return a False value, is a weird feature on their part. What ACF does before comparing a string, is checking if it can parse the strings as a date/datetime. If it can parse them as dates, then it will do so before comparison.
The user never asked for that, it’s weird, but that’s the reason you are seeing differences. Lucee is cool, ACF the weird one.
If your timeFormat method had a different output, which cannot be converted back to a date/time object, ACF would have said True as well:
<cfif timeformat(arguments.testTime,“hhXXXXXmm tt”) lt timeformat(arguments.currentTime,“hhXXXXXmm tt”)>
The easiest thing would have been, to first convert the time objects, like so:
<cfset testTime = parseDateTime(“6:45 PM”)>
<cfset currentTime = parseDateTime(“7:50 AM”)>
Just for the fun of it, I did some tests at cflive.net http://cflive.net/ between ACF and Lucee: (code is underneath)
(2000-01-01) lt (01/01/2020) = YES
(2000-01) lt (01/01/2020) = YES
(2000) lt (01/01/2020) = YES
(200) lt (01/01/20) = YES
(200) lt (01/) = NO
(20) lt (01) = NO
(01-12-2030) lt (12/02/2000) = NO
(01-12) lt (12/02) = YES
(01-12-2) lt (12/02/2) = YES
(01-12-203) lt (12/02/200) = NO
string (2000-01-01) lt (01/01/2020) = false
string (2000-01) lt (01/01/2020) = false
string (2000) lt (01/01/2020) = false
string (200) lt (01/01/20) = false
string (200) lt (01/) = false
string (20) lt (01) = false
string (01-12-2030) lt (12/02/2000) = true
string (01-12) lt (12/02) = true
string (01-12-2) lt (12/02/2) = true
string (01-12-203) lt (12/02/200) = true
Paul KlinkenbergOp 16 feb. 2016, om 14:04 heeft JD Yeiter <@JD_Yeiter> het volgende geschreven:
I came across this (bug?) when I was testing my app on Lucee. Basically, here’s the code that returned false on ACF and true on Lucee:
If I change the time format to “HH:mm tt”, then it returns FALSE on Lucee (as it should).
I just don’t know how Lucee compares time/date strings vs ACF. I guess the question is: is this a bug or expected behavior?
You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to firstname.lastname@example.org mailto:email@example.com.
To post to this group, send email to firstname.lastname@example.org mailto:email@example.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/2102f1c2-d118-4f21-a07c-f073a8d5954c%40googlegroups.com https://groups.google.com/d/msgid/lucee/2102f1c2-d118-4f21-a07c-f073a8d5954c%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.