lsParseDateTime

Hi everyone,
I am having an issue lsParseDateTime.
Here is my code that is failing

startOfYesterday = lsDateTimeFormat(yesterday, "yyyy-mm-dd") & " 00:00:00";
startOfYesterday_UTC = lsParseDateTime(date=startOfYesterday, timezone='UTC');

And here is the error;

Message can’t cast [2022-05-15 00:00:00] to date value
Detail to add custom formats for en_AU, create/extend on of the following files [en-AU-datetime.df (for date time formats), en-AU-date.df (for date formats) or en-AU-time.df (for time formats)] in the following directory [/lucee/locales].

if I dump startOfYesterday I get;

startOfYesterday
string	2022-05-15 00:00:00

And isDate(startOfYesterday) - returns true.

I can’t see anything obvious… Thanks - as always!
Gavin.

Lucee : 5.3.8.206
OS: Amazon Linux 2
Tomcat: 9.0.59
Java : openjdk 11.0.13 2021-10-19 LTS

I’ve reproduced this. Setting locale to the English - (Australia). then call the lsParseDateTime() throws the error.
Can you please file a bug in Jira?: https://luceeserver.atlassian.net
TryCF.com

Yup - Done.
https://luceeserver.atlassian.net/browse/LDEV-3994

Hi,
I have noticed that this has had some work done it - via the Jira ticket, thanks.

I have a question about Jira, now, please?
Is it anywhere in Jira (I couldn;t see it) that I can find the code changes made for this ticket?
Or is it a matter of just looking up a branch with the issue code?

Thanks!

mostly, the commit (code changes) done for the ticket is added in the comments of that ticket.
like [LDEV-3910] - Lucee

1 Like

Hi Everyone,

I am getting the following error - but what is weird about it is; in the ticket LDEV-3994, the workaround is to use “/” as a separator.
Which I have done - but it still fails… and with a message that I have never seen before - nor has google for that matter.

I have checked all of our servers (and my local/dev machine) and the only file in any /locale directory is pt-PT-date.df

Thanks for any help;
Gavin.

Message can’t cast [2022/05/30 00:00:00] to date value
Detail to add custom formats for en_AU, create/extend on of the following files [en-AU-datetime.df (for date time formats), en-AU-date.df (for date formats) or en-AU-time.df (for time formats)] in the following directory [/lucee/locales].
Stacktrace The Error Occurred in

/web/centra/dbsetup/scripts/customerBillingGC.cfm: line 83

81: // Now, tell them explicitly we want these to be UTC timestamps.
82: now_UTC = lsParseDateTime(date: today, timezone: ‘UTC’);
83: startOfYesterday_UTC = lsParseDateTime(date: startOfYesterday, timezone: ‘UTC’);|

Lucee : 5.3.8.206 AND 5.3.9.141
Tomcat: 9.0.59
Java: 11.0.13 RedHat
OS: 5.10.112-108.499.amzn2.x86_64

@Gavin_Baumanis The correct solution for this, we need to follow the instructions from the error details

Please create a file en-AU-datetime.df in web-context/lucee/locales with below content (ex- C:\lucee\tomcat\webapps\ROOT\WEB-INF\lucee\locales)

yyyy-MM-dd HH:mm:ss

And restart lucee/tomcat.

So now the lsParseDateTime() with locale en_AU supports date time string like 2022-05-15 00:00:00.

If you want to add more formats to be supported. Please append the format you want to support in a new line on that file like

yyyy/MM/dd HH:mm:ss
yyyy-MM-dd HH:mm:ss
yyyy-MM-dd
yyyy/MM/dd

So now these formats are supported by the lsParseDateTime() with en_AU.

Initially, I used lucee mask nn for Minute on en-AU-datetime.df file. So my checking is failed. Actually, the locale file needs java masks(mm for Minute) for that from here SimpleDateFormat (Java Platform SE 7 ).

Sorry for the previous incomplete workaround. Please use this solution and report here back.

Turns out - I am a bit of an idiot…

I couldn’t work out - why this was even needed… (The addition of a new file to state what should work with lsParseDateTime()

Now - a few days after - it’s finally sunk in;
Apart from the genuine bug that was found : our code is shit. and I should never assume that it was written correctly in the first place / or working as one would should expect.

For some reason - (as it was written) we were trying to force an “en_AU” locale specific formatting upon a dateTime - only the format we were trying to use - is NOT a format normally used in Australia.

So - the addition of the “df” file noted in the error is required to allow a non-standard format (for a specific locale) to be used in that locale - as if it was a standard / expected dateformat for the region.

Gavin.

2 Likes