You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Richard J. Barbalace (JIRA)" <de...@myfaces.apache.org> on 2006/11/16 23:12:39 UTC
[jira] Created: (TOMAHAWK-787) Incorrect display of 12-hour time in
t:inputCalendar
Incorrect display of 12-hour time in t:inputCalendar
----------------------------------------------------
Key: TOMAHAWK-787
URL: http://issues.apache.org/jira/browse/TOMAHAWK-787
Project: MyFaces Tomahawk
Issue Type: Bug
Components: Calendar
Affects Versions: 1.1.4-SNAPSHOT, 1.1.5-SNAPSHOT
Reporter: Richard J. Barbalace
If the date format attribute specifies 12-hour time, as in:
popupDateFormat="d MMM yyyy hh:mm:ss a"
rather than 24-hour time, as in:
popupDateFormat="d MMM yyyy HH:mm:ss"
then the display from the calendar still reports 24-hour time, yielding something like this:
Today is 16 Nov 2006 16:23:04 AM
That of course should read as:
Today is 16 Nov 2006 04:23:04 PM
I suspect the bug involves the code beginning around line 344 of
core/src/main/resources/org/apache/myfaces/custom/calendar/resource/date.js
which reads:
else if(patternSub.charAt(0)=='H' ||
patternSub.charAt(0)=='h')
There should probably be separate cases for 'H' and 'h', for which the latter would subtract 12 from the context.hour, but I am not familiar enough with this code to be sure. There might also be an issue with the AM/PM setting further down the file around line 381.
There are, in case anyone wonders why the time should be set from a calendar control, valid reasons for doing this, such as in my application where it is desired to be able to correct the date on an incorrectly entered timestamp from some other source.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (TOMAHAWK-787) Incorrect display of 12-hour time
in t:inputCalendar
Posted by "Simon Kitching (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/TOMAHAWK-787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556391#action_12556391 ]
Simon Kitching commented on TOMAHAWK-787:
-----------------------------------------
oops .. for some reason, the comment above was submitted incomplete. Here's the rest:
<t:inputCalendar id="secondOne" monthYearRowClass="yearMonthHeader" weekRowClass="weekHeader" popupButtonStyleClass="standard_bold"
currentDayCellClass="currentDayCell" value="#{calendarBean.secondDate}" renderAsPopup="true"
popupTodayString="#{example_messages['popup_today_string']}"
popupDateFormat="MM/dd/yyyy hh:mm:ss a" popupWeekString="#{example_messages['popup_week_string']}"
helpText="MM/DD/YYYY"
forceId="true"/>
<t:inputCalendar id="thirdOne" monthYearRowClass="yearMonthHeader" weekRowClass="weekHeader" popupButtonStyleClass="standard_bold"
currentDayCellClass="currentDayCell" value="#{calendarBean.secondDate}" renderAsPopup="true"
popupTodayString="#{example_messages['popup_today_string']}"
popupDateFormat="MM/dd/yyyy HH:mm:ss" popupWeekString="#{example_messages['popup_week_string']}"
helpText="MM/DD/YYYY"/>
Manually entering hours into the second field (24-hour time) causes the first field to correctly render 12-hour time.
Could you please retest with the latest Tomahawk snapshot from the apache snapshot repository here?
http://people.apache.org/repo/m2-snapshot-repository/org/apache/myfaces/tomahawk/tomahawk/1.1.7-SNAPSHOT/
> Incorrect display of 12-hour time in t:inputCalendar
> ----------------------------------------------------
>
> Key: TOMAHAWK-787
> URL: https://issues.apache.org/jira/browse/TOMAHAWK-787
> Project: MyFaces Tomahawk
> Issue Type: Bug
> Components: Calendar
> Affects Versions: 1.1.4-SNAPSHOT, 1.1.5-SNAPSHOT
> Reporter: Richard J. Barbalace
>
> If the date format attribute specifies 12-hour time, as in:
> popupDateFormat="d MMM yyyy hh:mm:ss a"
> rather than 24-hour time, as in:
> popupDateFormat="d MMM yyyy HH:mm:ss"
> then the display from the calendar still reports 24-hour time, yielding something like this:
> Today is 16 Nov 2006 16:23:04 AM
> That of course should read as:
> Today is 16 Nov 2006 04:23:04 PM
> I suspect the bug involves the code beginning around line 344 of
> core/src/main/resources/org/apache/myfaces/custom/calendar/resource/date.js
> which reads:
> else if(patternSub.charAt(0)=='H' ||
> patternSub.charAt(0)=='h')
> There should probably be separate cases for 'H' and 'h', for which the latter would subtract 12 from the context.hour, but I am not familiar enough with this code to be sure. There might also be an issue with the AM/PM setting further down the file around line 381.
> There are, in case anyone wonders why the time should be set from a calendar control, valid reasons for doing this, such as in my application where it is desired to be able to correct the date on an incorrectly entered timestamp from some other source.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (TOMAHAWK-787) Incorrect display of 12-hour time
in t:inputCalendar
Posted by "Simon Kitching (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/TOMAHAWK-787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556390#action_12556390 ]
Simon Kitching commented on TOMAHAWK-787:
-----------------------------------------
Hi Richard,
Yes you're quite right that H and h should be treated differently. The date-handling stuff has recently been completely rewritten and should now handle 12-hour time correctly. I've run the tomahawk "simple" example app, with calendar.jsp modified as follows, and it all appears to work ok:
> Incorrect display of 12-hour time in t:inputCalendar
> ----------------------------------------------------
>
> Key: TOMAHAWK-787
> URL: https://issues.apache.org/jira/browse/TOMAHAWK-787
> Project: MyFaces Tomahawk
> Issue Type: Bug
> Components: Calendar
> Affects Versions: 1.1.4-SNAPSHOT, 1.1.5-SNAPSHOT
> Reporter: Richard J. Barbalace
>
> If the date format attribute specifies 12-hour time, as in:
> popupDateFormat="d MMM yyyy hh:mm:ss a"
> rather than 24-hour time, as in:
> popupDateFormat="d MMM yyyy HH:mm:ss"
> then the display from the calendar still reports 24-hour time, yielding something like this:
> Today is 16 Nov 2006 16:23:04 AM
> That of course should read as:
> Today is 16 Nov 2006 04:23:04 PM
> I suspect the bug involves the code beginning around line 344 of
> core/src/main/resources/org/apache/myfaces/custom/calendar/resource/date.js
> which reads:
> else if(patternSub.charAt(0)=='H' ||
> patternSub.charAt(0)=='h')
> There should probably be separate cases for 'H' and 'h', for which the latter would subtract 12 from the context.hour, but I am not familiar enough with this code to be sure. There might also be an issue with the AM/PM setting further down the file around line 381.
> There are, in case anyone wonders why the time should be set from a calendar control, valid reasons for doing this, such as in my application where it is desired to be able to correct the date on an incorrectly entered timestamp from some other source.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (TOMAHAWK-787) Incorrect display of 12-hour time in
t:inputCalendar
Posted by "Richard J. Barbalace (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/TOMAHAWK-787?page=all ]
Richard J. Barbalace updated TOMAHAWK-787:
------------------------------------------
Status: Open (was: Patch Available)
> Incorrect display of 12-hour time in t:inputCalendar
> ----------------------------------------------------
>
> Key: TOMAHAWK-787
> URL: http://issues.apache.org/jira/browse/TOMAHAWK-787
> Project: MyFaces Tomahawk
> Issue Type: Bug
> Components: Calendar
> Affects Versions: 1.1.4-SNAPSHOT, 1.1.5-SNAPSHOT
> Reporter: Richard J. Barbalace
>
> If the date format attribute specifies 12-hour time, as in:
> popupDateFormat="d MMM yyyy hh:mm:ss a"
> rather than 24-hour time, as in:
> popupDateFormat="d MMM yyyy HH:mm:ss"
> then the display from the calendar still reports 24-hour time, yielding something like this:
> Today is 16 Nov 2006 16:23:04 AM
> That of course should read as:
> Today is 16 Nov 2006 04:23:04 PM
> I suspect the bug involves the code beginning around line 344 of
> core/src/main/resources/org/apache/myfaces/custom/calendar/resource/date.js
> which reads:
> else if(patternSub.charAt(0)=='H' ||
> patternSub.charAt(0)=='h')
> There should probably be separate cases for 'H' and 'h', for which the latter would subtract 12 from the context.hour, but I am not familiar enough with this code to be sure. There might also be an issue with the AM/PM setting further down the file around line 381.
> There are, in case anyone wonders why the time should be set from a calendar control, valid reasons for doing this, such as in my application where it is desired to be able to correct the date on an incorrectly entered timestamp from some other source.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Updated: (TOMAHAWK-787) Incorrect display of 12-hour time in
t:inputCalendar
Posted by "Richard J. Barbalace (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/TOMAHAWK-787?page=all ]
Richard J. Barbalace updated TOMAHAWK-787:
------------------------------------------
Status: Patch Available (was: Open)
> Incorrect display of 12-hour time in t:inputCalendar
> ----------------------------------------------------
>
> Key: TOMAHAWK-787
> URL: http://issues.apache.org/jira/browse/TOMAHAWK-787
> Project: MyFaces Tomahawk
> Issue Type: Bug
> Components: Calendar
> Affects Versions: 1.1.4-SNAPSHOT, 1.1.5-SNAPSHOT
> Reporter: Richard J. Barbalace
>
> If the date format attribute specifies 12-hour time, as in:
> popupDateFormat="d MMM yyyy hh:mm:ss a"
> rather than 24-hour time, as in:
> popupDateFormat="d MMM yyyy HH:mm:ss"
> then the display from the calendar still reports 24-hour time, yielding something like this:
> Today is 16 Nov 2006 16:23:04 AM
> That of course should read as:
> Today is 16 Nov 2006 04:23:04 PM
> I suspect the bug involves the code beginning around line 344 of
> core/src/main/resources/org/apache/myfaces/custom/calendar/resource/date.js
> which reads:
> else if(patternSub.charAt(0)=='H' ||
> patternSub.charAt(0)=='h')
> There should probably be separate cases for 'H' and 'h', for which the latter would subtract 12 from the context.hour, but I am not familiar enough with this code to be sure. There might also be an issue with the AM/PM setting further down the file around line 381.
> There are, in case anyone wonders why the time should be set from a calendar control, valid reasons for doing this, such as in my application where it is desired to be able to correct the date on an incorrectly entered timestamp from some other source.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (TOMAHAWK-787) Incorrect display of 12-hour time
in t:inputCalendar
Posted by "Richard J. Barbalace (JIRA)" <de...@myfaces.apache.org>.
[ http://issues.apache.org/jira/browse/TOMAHAWK-787?page=comments#action_12450579 ]
Richard J. Barbalace commented on TOMAHAWK-787:
-----------------------------------------------
I think the following changes may resolve the bug, which appears to work in my copy of date.js, but someone more familiar with the component than myself should create a patch and verify this.
At line 344:
else if(patternSub.charAt(0)=='H' ||
patternSub.charAt(0)=='h')
{
if(parse)
{
this._parseNum(context, dateStr,2,dateIndex);
context.hour = context.retValue;
}
else
{
if (patternSub.charAt(0)=='h' && context.hour >= 12) {
context.ampm = 1; // Set PM
}
if (patternSub.charAt(0)=='h' && context.hour == 0) {
context.hour = 12; // Adjust midnight hour
}
if (patternSub.charAt(0)=='h' && context.hour > 12) {
context.hour -= 12; // Adjust afternoon hours
}
this._formatNum(context,context.hour,patternSub.length);
}
}
Then at line 381:
else if(patternSub.charAt(0)=='a')
{
if(parse)
{
this._parseString(context, dateStr,dateIndex,this.dateFormatSymbols.ampms);
context.ampm = context.retValue;
if (context.ampm == 0 && context.hour == 12) {
context.hour = 0; // Adjust midnight hour
} else if (context.ampm == 1 && context.hour < 12) {
context.hour += 12; // Adjust afternoon hours
}
}
else
{
context.dateStr += this.dateFormatSymbols.ampms[context.ampm];
}
}
> Incorrect display of 12-hour time in t:inputCalendar
> ----------------------------------------------------
>
> Key: TOMAHAWK-787
> URL: http://issues.apache.org/jira/browse/TOMAHAWK-787
> Project: MyFaces Tomahawk
> Issue Type: Bug
> Components: Calendar
> Affects Versions: 1.1.4-SNAPSHOT, 1.1.5-SNAPSHOT
> Reporter: Richard J. Barbalace
>
> If the date format attribute specifies 12-hour time, as in:
> popupDateFormat="d MMM yyyy hh:mm:ss a"
> rather than 24-hour time, as in:
> popupDateFormat="d MMM yyyy HH:mm:ss"
> then the display from the calendar still reports 24-hour time, yielding something like this:
> Today is 16 Nov 2006 16:23:04 AM
> That of course should read as:
> Today is 16 Nov 2006 04:23:04 PM
> I suspect the bug involves the code beginning around line 344 of
> core/src/main/resources/org/apache/myfaces/custom/calendar/resource/date.js
> which reads:
> else if(patternSub.charAt(0)=='H' ||
> patternSub.charAt(0)=='h')
> There should probably be separate cases for 'H' and 'h', for which the latter would subtract 12 from the context.hour, but I am not familiar enough with this code to be sure. There might also be an issue with the AM/PM setting further down the file around line 381.
> There are, in case anyone wonders why the time should be set from a calendar control, valid reasons for doing this, such as in my application where it is desired to be able to correct the date on an incorrectly entered timestamp from some other source.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira