Jump to:
| Project: | YUI Calendar |
| Version: | 6.x-1.1-4 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
When using yui_calendar on my test machine (6.2 stable), the date loaded into the text field is one day different from the day selected. I found in the JavaScript [yuicalendar.js]:
YAHOO.drupal.calendar.handleSelect = function(type, args, obj, myCal) {
var dates = args[0];
var date = dates[0];
var year = date[0], month = date[1], day = date[2];
YAHOO.util.Dom.get(myCal.id + '-year').selectedIndex = Math.abs(year - 1969 - YAHOO.util.Dom.get(myCal.id + '-year').length + 1);
YAHOO.util.Dom.get(myCal.id + '-month').selectedIndex = month - 1;
YAHOO.util.Dom.get(myCal.id + '-day').selectedIndex = day - 1;
YAHOO.drupal.calendar.updateDateValue(myCal);
};
When I comment out the subtraction of a day, the day in the text field displays correctly. I'm attaching a patch with that tiny edit.
Honestly, I'm a bit hesitant about this edit, as I'm unclear what the subtraction did in the first place.
Comments
#1
I see the same problem when importing nodes from csv with node_import. I think your problem is not related to YUI (which I have, but switched off). You mention the problem occurs sometimes, as it does for me. Have you been able to see any pattern in when it appears?
From my very shallow understanding of this, I think days and months are represented zero-based, ie January is represented as the 0th month. Hence the -1 on statements in the code.