Author: pyaschenko
Date: 2011-02-04 13:37:54 -0500 (Fri, 04 Feb 2011)
New Revision: 21465
Modified:
trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar-utils.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
Log:
https://jira.jboss.org/browse/RF-8161
Modified: trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2011-02-04 18:31:43
UTC (rev 21464)
+++ trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2011-02-04 18:37:54
UTC (rev 21465)
@@ -46,7 +46,7 @@
jointPoint="#{calendarBean.jointPoint}"
direction="#{calendarBean.direction}"
locale="#{calendarBean.locale}" popup="#{calendarBean.popup}"
datePattern="#{calendarBean.pattern}"
- dataModel="#{calendarDataModel}"
+
mode="#{calendarBean.mode}"
disabled="false"
cellWidth="24px"
@@ -65,7 +65,7 @@
ondatemouseover="return onEvent.call(this, event);"
firstWeekDay="4"
horizontalOffset="#{calendarBean.horizontalOffset}"
- verticalOffset="#{calendarBean.verticalOffset}"
defaultTime="21:22:01" timeZone="#{calendarBean.timeZone}"
+ verticalOffset="#{calendarBean.verticalOffset}"
defaultTime="00:00:00" timeZone="#{calendarBean.timeZone}"
valueChangeListener="#{calendarBean.doValueChangeListener}"
currentDataChangeListener="#{calendarBean.doCurrentDataChangeListener}"
onbeforedateselect="myFunction(event)"
@@ -105,8 +105,8 @@
<f:selectItem itemLabel="d/M/yy HH:mm" itemValue="d/M/yy
HH:mm" />
<f:selectItem itemLabel="dd/M/yy hh:mm a"
itemValue="dd/M/yy hh:mm a" />
- <f:selectItem itemLabel="dd/M/yy hh:mm:ss"
- itemValue="dd/M/yy hh:mm:ss" />
+ <f:selectItem itemLabel="dd/M/yy HH:mm:ss"
+ itemValue="dd/M/yy HH:mm:ss" />
<f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y" />
<f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy"
/>
</h:selectOneMenu>
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar-utils.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar-utils.js 2011-02-04
18:31:43 UTC (rev 21464)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar-utils.js 2011-02-04
18:37:54 UTC (rev 21465)
@@ -79,6 +79,17 @@
i++;
}
},
+
+ createDate: function (yy,mm,dd,h,m,s) {
+ h=h||0; m=m||0; s=s||0;
+ var date = new Date(yy, mm, dd, h, m, s);
+ if (date.getDate()!=dd) {
+ date = new Date(yy, mm);
+ date.setHours(h); date.setMinutes(m); date.setSeconds(s);
+ date.setUTCDate(dd);
+ }
+ return date;
+ },
/* Year:
* y,yy - 00-99
@@ -165,7 +176,7 @@
var addDay = correctYear ? 1 : 0;
var dd = parseInt(match[d],10); if (isNaN(dd) || dd<1 ||
dd>this.daysInMonth(yy, mm) + addDay) return null;
- var date = new Date(yy, mm, dd);
+ var date;
// time parsing
if (min!=undefined && h!=undefined)
@@ -186,12 +197,14 @@
}
else if (hh<0 || hh>23) return null;
- date.setHours(hh); date.setMinutes(mmin);
+ date = this.createDate(yy, mm, dd, hh, mmin);
if (s!=undefined)
{
sec = parseInt(match[s], 10); if (isNaN(sec) || sec<0 || sec>59) return
null;
date.setSeconds(sec);
}
+ } else {
+ date = this.createDate(yy, mm, dd);
}
if (correctYear) {
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2011-02-04
18:31:43 UTC (rev 21464)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2011-02-04
18:37:54 UTC (rev 21465)
@@ -932,7 +932,8 @@
if (this.options.defaultLabel) {
if (!this.isFocused) updateDefaultLabel.call(this, "");
- } else if (baseInput.value!=undefined)
+ }
+ if (baseInput.value)
{
this.__selectDate(baseInput.value, false, {event:e, element:element});
}
@@ -1040,20 +1041,17 @@
},
setupTimeForDate: function (date) {
+ var result = new Date(date);
if (this.selectedDate && (!this.options.resetTimeOnDateSelect ||
(this.selectedDate.getFullYear() == date.getFullYear() &&
this.selectedDate.getMonth() == date.getMonth() &&
this.selectedDate.getDate() == date.getDate())))
{
- date.setHours(this.selectedDate.getHours());
- date.setMinutes(this.selectedDate.getMinutes());
- date.setSeconds(this.selectedDate.getSeconds());
- } else
- {
- date.setHours(this.options.defaultTime.hours);
- date.setMinutes(this.options.defaultTime.minutes);
- date.setSeconds(this.options.defaultTime.seconds);
+ result = rf.calendarUtils.createDate(date.getFullYear(), date.getMonth(),
date.getDate(), this.selectedDate.getHours(), this.selectedDate.getMinutes(),
this.selectedDate.getSeconds());
+ } else {
+ result = rf.calendarUtils.createDate(date.getFullYear(), date.getMonth(),
date.getDate(), this.options.defaultTime.hours, this.options.defaultTime.minutes,
this.options.defaultTime.seconds);
}
+ return result;
},
eventCellOnClick: function (e, obj) {
@@ -1061,10 +1059,10 @@
if (daydata.enabled && daydata._month==0)
{
var date=new Date(this.currentDate);
- date.setDate(daydata.day);
+ date.setUTCDate(daydata.day);
if (this.timeType)
{
- this.setupTimeForDate(date);
+ date = this.setupTimeForDate(date);
}
if (this.__selectDate(date,true, {event:e, element:obj}) &&
!this.options.showApplyButton)
@@ -1080,7 +1078,7 @@
var date = new Date(daydata.date);
if (this.timeType)
{
- this.setupTimeForDate(date);
+ date = this.setupTimeForDate(date);
}
if (this.__selectDate(date, false, {event:e, element:obj}) &&
!this.options.showApplyButton)
@@ -1557,10 +1555,11 @@
{
var daydata =
this.days[parseInt(this.todayCellId.substr(this.DATE_ELEMENT_ID.length),10)];
var today = new Date();
- var date = new Date(today.getFullYear(), today.getMonth(), today.getDate());
+ var date = new Date(today.getFullYear(), today.getMonth());
+ date.setUTCDate(today.getDate());
if (this.timeType)
{
- this.setupTimeForDate(date);
+ date = this.setupTimeForDate(date);
}
if (daydata.enabled && this.__selectDate(date,true) &&
!this.options.showApplyButton)
{
@@ -1799,7 +1798,7 @@
if (h!=12) h+=12;
}
}
- var date = new Date(this.selectedDate.getFullYear(), this.selectedDate.getMonth(),
this.selectedDate.getDate(), h, m, s);
+ var date = rf.calendarUtils.createDate(this.selectedDate.getFullYear(),
this.selectedDate.getMonth(), this.selectedDate.getDate(), h, m, s);
if (date-this.selectedDate &&
this.invokeEvent("beforetimeselect",null, null, date))
{
this.selectedDate = date;