[jira] [Commented] (FREEMARKER-95) Wrong day of the week shown for the Thai locale

2018-05-07 Thread James Barnes (JIRA)

[ 
https://issues.apache.org/jira/browse/FREEMARKER-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16466413#comment-16466413
 ] 

James Barnes commented on FREEMARKER-95:


So sorry, I thought I had responded! Yes, adding iso fixed the issue, so it can 
be closed :) Thanks for your help!

> Wrong day of the week shown for the Thai locale
> ---
>
> Key: FREEMARKER-95
> URL: https://issues.apache.org/jira/browse/FREEMARKER-95
> Project: Apache Freemarker
>  Issue Type: Bug
>Reporter: James Barnes
>Priority: Major
>
> Freemarker returns the wrong day of the week when the user sets the the 
> locale to Thai. It would seem that this is a result of Freemarker not 
> correcting for the Buddhist calendar. The day of the week is currently out of 
> sync but will be back in sync on Feb 28 2019 and then will be out of sync 
> again on Feb 29 2020. So currently when the user sets the locale to Thai, 
> FreeMarker uses the days of the week from 1475 on the Gregorian calendar.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FREEMARKER-95) Wrong day of the week shown for the Thai locale

2018-04-26 Thread Daniel Dekany (JIRA)

[ 
https://issues.apache.org/jira/browse/FREEMARKER-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=1644#comment-1644
 ] 

Daniel Dekany commented on FREEMARKER-95:
-

Is {{payload.bookingDate}} a {{String}}, which stores the date in Gergorian 
format? Because then of course you get the result what you get. As your locale 
is {{th_TH}}, the string is interpreted according to that locale. My example 
works because it uses ISO format, which is always interpreted as Gergorian.

To avoid such problems, either use {{java.sql.Date}} (maybe {{java.util.Date}}) 
for {{payload.bookingDate}}, or use ISO format. (Or, use Thai format, but 
that's not an option if you serve multiple locales.)

As of a date-only value has no time zone attached... FreeMarker is based on 
traditional Java date/time handling (i.e., {{java.util.Date}}), where time 
zones matter even then. So be careful about that... (Like there's an example of 
that kind of mess: [SQLDateAndTimeTimeZone 
setting|https://freemarker.apache.org/docs/api/freemarker/core/Configurable.html#setSQLDateAndTimeTimeZone-java.util.TimeZone-])

> Wrong day of the week shown for the Thai locale
> ---
>
> Key: FREEMARKER-95
> URL: https://issues.apache.org/jira/browse/FREEMARKER-95
> Project: Apache Freemarker
>  Issue Type: Bug
>Reporter: James Barnes
>Priority: Major
>
> Freemarker returns the wrong day of the week when the user sets the the 
> locale to Thai. It would seem that this is a result of Freemarker not 
> correcting for the Buddhist calendar. The day of the week is currently out of 
> sync but will be back in sync on Feb 28 2019 and then will be out of sync 
> again on Feb 29 2020. So currently when the user sets the locale to Thai, 
> FreeMarker uses the days of the week from 1475 on the Gregorian calendar.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FREEMARKER-95) Wrong day of the week shown for the Thai locale

2018-04-26 Thread James Barnes (JIRA)

[ 
https://issues.apache.org/jira/browse/FREEMARKER-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16454904#comment-16454904
 ] 

James Barnes commented on FREEMARKER-95:


Also, if it were a timezone issue, we would never see our results sync up with 
the correct output, but we do.

> Wrong day of the week shown for the Thai locale
> ---
>
> Key: FREEMARKER-95
> URL: https://issues.apache.org/jira/browse/FREEMARKER-95
> Project: Apache Freemarker
>  Issue Type: Bug
>Reporter: James Barnes
>Priority: Major
>
> Freemarker returns the wrong day of the week when the user sets the the 
> locale to Thai. It would seem that this is a result of Freemarker not 
> correcting for the Buddhist calendar. The day of the week is currently out of 
> sync but will be back in sync on Feb 28 2019 and then will be out of sync 
> again on Feb 29 2020. So currently when the user sets the locale to Thai, 
> FreeMarker uses the days of the week from 1475 on the Gregorian calendar.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FREEMARKER-95) Wrong day of the week shown for the Thai locale

2018-04-26 Thread James Barnes (JIRA)

[ 
https://issues.apache.org/jira/browse/FREEMARKER-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16454897#comment-16454897
 ] 

James Barnes commented on FREEMARKER-95:


It refers to the Gregorian year 1475 due to the 543 year difference between the 
two calendars. This has been confirmed because I have tested when the leap 
years would line up, FreeMarker syncs up with the correct output on March 1 
2019 Gregorian and goes out of sync on March 2020. This a result of 543 mod 4 = 
3, implying the output would be sync for a year and out of sync for 3 years. It 
is not a timezone issue because I should have specified earlier but we are 
using Date (which does not have a timezone attached to it) not Datetime. 
Additionally, our application handles ~20 different languages and Thai is the 
only language that gives us issues.   Our {{payload.bookingDate}} would be a 
date with an example value of "04-26-2018".

 

So let me try and clarify my description of the bug. The issue occurs when 
FreeMarker is given a Gregorian calendar date(such as "04-26-2018") and a 
Locale of "th_TH", it interprets the date as a Buddhist calendar date and 
returns the BuddhistCalendar results for 04-26-2018 (or 04-26-1475 Gregorian). 
This is not a Java issue because if you run the code provided above Gregorian 
dates do not need to be explicitly defined and the correct results are returned 
with the Thai Locale. We are using Java Dates so timezone cannot be the issue. 
Maybe you are not reproducing the issue with Datetimes is because with an 
attached timezone, FreeMarker is properly recognizing it as a Gregorian 
datetime, but this would just be a guess.

 

> Wrong day of the week shown for the Thai locale
> ---
>
> Key: FREEMARKER-95
> URL: https://issues.apache.org/jira/browse/FREEMARKER-95
> Project: Apache Freemarker
>  Issue Type: Bug
>Reporter: James Barnes
>Priority: Major
>
> Freemarker returns the wrong day of the week when the user sets the the 
> locale to Thai. It would seem that this is a result of Freemarker not 
> correcting for the Buddhist calendar. The day of the week is currently out of 
> sync but will be back in sync on Feb 28 2019 and then will be out of sync 
> again on Feb 29 2020. So currently when the user sets the locale to Thai, 
> FreeMarker uses the days of the week from 1475 on the Gregorian calendar.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FREEMARKER-95) Wrong day of the week shown for the Thai locale

2018-04-26 Thread James Barnes (JIRA)

[ 
https://issues.apache.org/jira/browse/FREEMARKER-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16454894#comment-16454894
 ] 

James Barnes commented on FREEMARKER-95:


It refers to the Gregorian year 1475 due to the 543 year difference between the 
two calendars. This has been confirmed because I have tested when the leap 
years would line up, FreeMarker syncs up with the correct output on March 1 
2019 Gregorian and goes out of sync on March 2020. This a result of 543 mod 4 = 
3, implying the output would be sync for a year and out of sync for 3 years. It 
is not a timezone issue because I should have specified earlier but we are 
using Date (which does not have a timezone attached to it) not Datetime. 
Additionally, our application handles ~20 different languages and Thai is the 
only language that gives us issues.   So our {{payload.bookingDate}} would be a 
date with an example value of "04-26-2018".

 

So let me try and clarify my description of the bug. The issue occurs when 
FreeMarker is given a Gregorian calendar date(such as "04-26-2018") and a 
Locale of "th_TH", it interprets the date as a Buddhist calendar date and 
returns the BuddhistCalendar results for 04-26-2018 (or 04-26-1475 Gregorian). 
This is not a Java issue because if you run the code provided above Gregorian 
dates do not need to be explicitly defined and the correct results are returned 
with the Thai Locale. We are using Java Dates so timezone cannot be the issue. 
Maybe you are not reproducing the issue with Datetimes is because with an 
attached timezone, FreeMarker is properly recognizing it as a Gregorian 
datetime, but this would just be a guess.

 

> Wrong day of the week shown for the Thai locale
> ---
>
> Key: FREEMARKER-95
> URL: https://issues.apache.org/jira/browse/FREEMARKER-95
> Project: Apache Freemarker
>  Issue Type: Bug
>Reporter: James Barnes
>Priority: Major
>
> Freemarker returns the wrong day of the week when the user sets the the 
> locale to Thai. It would seem that this is a result of Freemarker not 
> correcting for the Buddhist calendar. The day of the week is currently out of 
> sync but will be back in sync on Feb 28 2019 and then will be out of sync 
> again on Feb 29 2020. So currently when the user sets the locale to Thai, 
> FreeMarker uses the days of the week from 1475 on the Gregorian calendar.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FREEMARKER-95) Wrong day of the week shown for the Thai locale

2018-04-26 Thread James Barnes (JIRA)

[ 
https://issues.apache.org/jira/browse/FREEMARKER-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16454633#comment-16454633
 ] 

James Barnes commented on FREEMARKER-95:


Thank you for such a quick response! So I think the issue is that when I set 
the locale to Thai in FreeMarker with code that looks like this:
{code:java}
room=<#setting locale="th_TH"><#setting 
date_format="-MM-dd">คุณมีการจองใหม่สำหรับวันที่ 
${payload.bookingDate?date?string.full}{code}
FreeMarker uses the Buddhist calendar to look up the day of the week, without 
first converting the year. So if the day in question were today (Thursday April 
26 2018), FreeMarker returns Wednesday April 26 2018 in Thai, but is actually 
referring to Wednesday April 26 1475. Initially, I also thought it might have 
been an issue with Java 8 as well, but if I run this simple Java:
{code:java}
String date_s = " 2018-04-26";

        SimpleDateFormat dt = new SimpleDateFormat("-MM-dd");

        Locale th_TH = new Locale("th", "TH");

        try {

            Date date = dt.parse(date_s);

            SimpleDateFormat dt1 = new SimpleDateFormat(" MM-dd-", 
th_TH);

            SimpleDateFormat dt2 = new SimpleDateFormat(" MM-dd-");

            System.out.println(dt1.format(date));

            System.out.println(dt2.format(date));

        } catch(Exception e){

            System.out.println(e.toString());

        }
{code}
I get the correct day of the week and year: วันพฤหัสบดี 04-26-2561 (Thursday 
04-26-2018). We are actually only interested in the date itself, so no 
timezones are being passed, just "MM-dd-". Let me know if you have any 
clarification questions on our use case.

> Wrong day of the week shown for the Thai locale
> ---
>
> Key: FREEMARKER-95
> URL: https://issues.apache.org/jira/browse/FREEMARKER-95
> Project: Apache Freemarker
>  Issue Type: Bug
>Reporter: James Barnes
>Priority: Major
>
> Freemarker returns the wrong day of the week when the user sets the the 
> locale to Thai. It would seem that this is a result of Freemarker not 
> correcting for the Buddhist calendar. The day of the week is currently out of 
> sync but will be back in sync on Feb 28 2019 and then will be out of sync 
> again on Feb 29 2020. So currently when the user sets the locale to Thai, 
> FreeMarker uses the days of the week from 1475 on the Gregorian calendar.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)