dateDiff member function throws error for dateTimeformat string

Description

dateDiff member function throws an error like The function [ diff ] does not exist in the String for date formatted string (Ex:-"23-Mar-2021 15:11:52").

now().diff("s",now()) // works in both ACF and lucee dateTimeFormat(now()).diff("s",now()) // works in ACF and throws error in lucee

seems dateDiff() works fine in both conditions.

Environment

None

Activity

Show:

Zac Spitzer 27 May 2022 at 14:58
Edited

fair enough, isDate is like the 5 year child who answers yes they know to every question eh?

Pothys - MitrahSoft 27 May 2022 at 14:46
Edited

args <= 3, There is no dateTime member function that has more than 3 args in lucee. So it skips the isDateAdvanced check for more than 3 args.

max length checks in isDateAdvanced() have a chances to break the BIF isDate() and other areas. Please see the below tryCF
https://trycf.com/gist/3bdfd081d9a09e11a78205e795459fdc/lucee5?theme=monokai

Zac Spitzer 27 May 2022 at 14:20

ok, but the args check for 3 only applies for this date function?

Probably better moving those checks into isDateAdvanced, plus a max length check?

Pothys - MitrahSoft 26 May 2022 at 14:46

Yeah zac, It’s good to avoid the overhead of isDateAdvanced() by some checks.

I added checks for min length, args length, and isInteger to avoid it.
https://github.com/lucee/Lucee/pull/1650/commits/f516e186fc0aa9e2ad6880b1ce34ddcc92363714
https://github.com/lucee/Lucee/pull/1650/commits/36c1f4865e78e67926a5cac6656b3cc0122111ba

Zac Spitzer 26 May 2022 at 12:31
Edited

nice work, but i think Lucee is correct here,

I don’t think we want to be trying to convert a string to date everytime we go looking for potential member functions?

if we do, looking into isDateAdvanced() we could avoid some overhead with some basic checks?

if not min length, or max length, or with two args, skip the check?

Fixed

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Affects versions

Created 23 March 2021 at 09:54
Updated 11 November 2024 at 16:13
Resolved 21 May 2024 at 19:28

Flag notifications