Dateformat weirdness

Hi Everyone,
I am having a WTF moment…

I have a form where the date is entered in AUSTRALIAN format DD/MM/YYYY

On the form it is submitted to I have the following code;
form: #form.startdate#

US: #dateformat(form.startdate, “MM-DD-YYYY”)#

AU: #dateformat(form.startdate, “DD-MM-YYYY”)#

ISO: #dateformat(form.startdate, “YYYY-MM-DD”)#

here is the output.

form: 01/07/2015
US: 01-07-2015
AU: 07-01-2015
ISO: 2015-01-07

The Windows server locale is set to Australia.
The Lucee region is set to australia - and shows the date and time in
Australian format correctly.

Can anyone explain what I am doing wrong?
Is there a bug?

Thanks!

Try LSDateFormat instead. I believe only the “LS” function use the locale.

Kind regards,

Andrew
about.me http://about.me/andrew_dixon - mso http://www.mso.net - Lucee
Member http://lucee.orgOn 7 May 2015 at 10:09, Gavin Baumanis <@Gavin_Baumanis> wrote:

Hi Everyone,
I am having a WTF moment…

I have a form where the date is entered in AUSTRALIAN format DD/MM/YYYY

On the form it is submitted to I have the following code;
form: #form.startdate#

US: #dateformat(form.startdate, “MM-DD-YYYY”)#

AU: #dateformat(form.startdate, “DD-MM-YYYY”)#

ISO: #dateformat(form.startdate, “YYYY-MM-DD”)#

here is the output.

form: 01/07/2015
US: 01-07-2015
AU: 07-01-2015
ISO: 2015-01-07

The Windows server locale is set to Australia.
The Lucee region is set to australia - and shows the date and time in
Australian format correctly.

Can anyone explain what I am doing wrong?
Is there a bug?

Thanks!


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 lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/470881f7-3f82-438a-a895-bff2c50005e9%40googlegroups.com
https://groups.google.com/d/msgid/lucee/470881f7-3f82-438a-a895-bff2c50005e9%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

Here is a trycf.com gist to show that using LSDateFormat works:

Kind regards,

Andrew
about.me http://about.me/andrew_dixon - mso http://www.mso.net - Lucee
Member http://lucee.orgOn 7 May 2015 at 12:09, Nando Breiter <@Nando_Breiter> wrote:

What may be happening is that by default, dateformat() interprets a date
that could be MM/DD or DD/MM in the American way, MM/DD. What I don’t know
is if Lucee will correctly interpret the date if you use LSDateFormat.

I’ve run into this on ACF, and use the date widget from jQuery to work
around it, basically to ensure a date is always submitted in the
unambiguous YYYY-MM-DD format, and displayed to the user consistently and
correctly in the DD-MM-YYYY format. I’d do the same on Lucee, even if I
found a correct pathway through this morass, simply to ensure that dates
are always represented in a consistent way, especially for functions like
DateAdd(), for example.

Aria Media Sagl
Via Rompada 40
6987 Caslano
Switzerland

+41 (0)91 600 9601
+41 (0)76 303 4477 cell
skype: ariamedia

On Thu, May 7, 2015 at 12:23 PM, Julian Halliwell < @Julian_Halliwell> wrote:

Or parse the form value to an Aussie date before passing it to the
standard formatting functions:

form.startdate = LsParseDateTime( form.startdate );

On 7 May 2015 at 11:02, Andrew Dixon <@Andrew_Dixon> wrote:

Try LSDateFormat instead. I believe only the “LS” function use the
locale.


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 lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/CAC_5VopCzm7tm7wo5svVBBT6oi%3DiCmoAQa04B9bkf9%3DZ_4xaKQ%40mail.gmail.com
.
For more options, visit https://groups.google.com/d/optout.


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 lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/CAGHrs%3D-unja4_nGm3sLBKqmg%2Ba%3D3QvCGR9YQ%2BsaidQJC6AZWDQ%40mail.gmail.com
https://groups.google.com/d/msgid/lucee/CAGHrs%3D-unja4_nGm3sLBKqmg%2Ba%3D3QvCGR9YQ%2BsaidQJC6AZWDQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.

DateFormat ignore your locale settings completely, this function only using
the US date locale, let me explain what is exactly going on in your
examples.

dateformat(“01/07/2015”, “MM-DD-YYYY”)
the date string with the first argument is parsed to a date object using us
“locale” rules (month/day/year) what means inside the function we have the
a date object for the 7th of january 2015.
This date then is converted to a string using the pattern you have defined.
So the outcome is as expected and “correct”.
I completely agree that this behaviour is weird if you not using an us
locale for your environment.
There is one simple reason for this, the date functions are pure us locale
based and ignore every other locale set, simply because locale and the “LS”
function was introduced later (in Macromedia CF?), so for backward
compatibility they work still the classic way.
we should even consider to deprecate them for Lucee 5!

BTW in the Lucee dialect from Lucee 5 we have removed ALL this date/time
function and removed the “LS” from the “LS” function, so in the
Lucee dialect your code will work as expected!

MichaOn Thu, May 7, 2015 at 11:09 AM, Gavin Baumanis <@Gavin_Baumanis> wrote:

Hi Everyone,
I am having a WTF moment…

I have a form where the date is entered in AUSTRALIAN format DD/MM/YYYY

On the form it is submitted to I have the following code;
form: #form.startdate#

US: #dateformat(form.startdate, “MM-DD-YYYY”)#

AU: #dateformat(form.startdate, “DD-MM-YYYY”)#

ISO: #dateformat(form.startdate, “YYYY-MM-DD”)#

here is the output.

form:
US: 01-07-2015
AU: 07-01-2015
ISO: 2015-01-07

The Windows server locale is set to Australia.
The Lucee region is set to australia - and shows the date and time in
Australian format correctly.

Can anyone explain what I am doing wrong?
Is there a bug?

Thanks!


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 lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/470881f7-3f82-438a-a895-bff2c50005e9%40googlegroups.com
https://groups.google.com/d/msgid/lucee/470881f7-3f82-438a-a895-bff2c50005e9%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.