Locales, Date Formats and LSIsDate


#1

Hi Everyone,

I’m at the business end of migrating a fairly large application from ACF to Lucee, it’s been mostly ok but I am now encountering some issues with dates that are doing my head in.

In the application it is possible to choose a display date format that is different to the standard for your locale and many europeans choose to use DD/MM/YYYY.

What I am finding is that for ACF both DD/MM/YYYY and DD-MM-YY will pass ok with LSIsDate when the locale is set to nl_NL. However when we run the same code in Lucee I find that LSIsDate fails for DD/MM/YYYY and passes for DD-MM-YY and this is going to be a real problem for us.

Any help and suggestions would be much appreciated!

Brett
B)


#2

Looks like you’ll need to add custom formats for nl_NL, create/extend on of the following files [nl-NL-datetime.df (for date time formats), nl-NL-date.df (for date formats) or nl-NL-time.df (for time formats)] in the following directory [/lucee/locales].

Got this info from running this bit of code w/ my server locale set to Netherlands(nl_NL):

<cfset dateUS="10/24/2015">
<cfset dateEU="24/10/2015">
<cfset dashdateUS="10-24-2015">
<cfset dashdateEU="24-10-2015">

<cfoutput>
Locale: #GetLocale()#<br>

dateUS:#lsIsDate(dateUS,GetLocale())#<br>
dateEU:#lsIsDate(dateEU,GetLocale())#<br>
dashdateUS:#lsIsDate(dashdateUS,GetLocale())#<br>
dashdateEU:#lsIsDate(dashdateEU,GetLocale())#<br>
<hr>
dateUS:#IsDate(dateUS)#<br>
dateEU:#IsDate(dateEU)#<br>
dashdateUS:#IsDate(dashdateUS)#<br>
dashdateEU:#IsDate(dashdateEU)#<br>

<hr>
using conversion method<br>
<cfset dateUSConv = lsParseDateTime(dateUS,GetLocale())>
<cfset dateEUConv = lsParseDateTime(dateEU,GetLocale())>
<cfset datedashUSConv = lsParseDateTime(datedashUS,GetLocale())>
<cfset datedashEUConv = lsParseDateTime(datedashEU,GetLocale())>

dateUS:#IsDate(dateUSconv)#<br>
dateEU:#IsDate(dateEUconv)#<br>
dashdateUS:#IsDate(dashdateUSconv)#<br>
dashdateEU:#IsDate(dashdateEUconv)#<br>
</cfoutput>

suprisingly, the error code generated from the first parsedatetime that fails gives the answer. Hope this helps.