PDA

View Full Version : DateMenu bug with March 29th, 30th and 31st.



sdrew
27 Mar 2007, 9:27 AM
The calendar displays the wrong days if you select March 29th, 30th or 31st.

ie, it shows March 30th 2007 as a Tuesday instead of Friday.


<script language="javascript">
Ext.onReady(function() {
var cfg = { menu: new Ext.menu.DateMenu(), allowBlank:true, format:'Y-m-d'};
var df = new Ext.form.DateField(cfg);
df.applyTo('EndDate');
} );
</script>
<form name="form" action="" method="get">
<input name="EndDate" value="2007-03-30" id="EndDate" />
</form>

tryanDLS
27 Mar 2007, 10:19 AM
I think you're incorrectly accessing the field value. df.getValue() will return the selected date as a Date object. df.value is just a string (e.g. 2007-03-30). If you pass that to Date(), it's going to see it as an invalid date and return the current date, which is Tues Mar 27 2007

sdrew
27 Mar 2007, 12:25 PM
I dont think so, I am not doing a getValue or reading the date, just the code above and when you click on the field to open the calendar control it displays the wrong date. Every other date works except for march 29,30,31.

Ie the rendered calendar is wrong its showing Feburary layout, but the title says March and the days are wrong.

tryanDLS
27 Mar 2007, 1:54 PM
Hmm, maybe there's an off-by-one bug in the date calc, and it's looking at valid days for February.

philiphachey
29 Mar 2007, 9:47 AM
The following code is commented out of the Date.prototype.add function in Date.js. I don't know why it's commented out, because having it there clearly conforms to the spirit of the function. Uncomment it and this should reslove your problem. I just ran into this myself:

/*
var day = this.getDate();
if(day > 28){
day = Math.min(day, this.getFirstDateOfMonth().add('mo', value).getLastDateOfMonth().getDate());
}
d.setDate(day);*/
[EDIT]: I should point out that this is for Ext 1.0 Alpha 3 rev 4

jack.slocum
29 Mar 2007, 1:32 PM
I commented that out in a recent release. I ass-umed it was no longer needed. It will work correctly in the next release.