MDL-39190 Javascript: Pop-up calendar days of week wrong
The YUI2 calendar widget (still used via 2in3) uses midnight as the time component of its Date objects, which triggers a Safari bug resulting in 11pm Saturday being returned instead of midnight Sunday when subtracting days to get the last few days of the previous month. This shows up ONLY on the month after DST begins, if DST begins on the last Sunday of a given month (and the Calendar widget is set to Sunday as the first day of the week). The fix/workaround of using noon instead of midnight is employed by YUI3 and others.
This commit is contained in:
@@ -1062,8 +1062,9 @@ YAHOO.widget.DateMath = {
|
||||
|
||||
/**
|
||||
* Returns a new JavaScript Date object, representing the given year, month and date. Time fields (hr, min, sec, ms) on the new Date object
|
||||
* are set to 0. The method allows Date instances to be created with the a year less than 100. "new Date(year, month, date)" implementations
|
||||
* set the year to 19xx if a year (xx) which is less than 100 is provided.
|
||||
* are set to 0, except the hour which is set to 12 (noon) to avoid issues around the start of Daylight Savings Time. The method allows Date
|
||||
* instances to be created with the a year less than 100. "new Date(year, month, date)" implementations set the year to 19xx if a year (xx)
|
||||
* which is less than 100 is provided.
|
||||
* <p>
|
||||
* <em>NOTE:</em>Validation on argument values is not performed. It is the caller's responsibility to ensure
|
||||
* arguments are valid as per the ECMAScript-262 Date object specification for the new Date(year, month[, date]) constructor.
|
||||
@@ -1080,13 +1081,13 @@ YAHOO.widget.DateMath = {
|
||||
d = 1;
|
||||
}
|
||||
if (y >= 100) {
|
||||
dt = new Date(y, m, d);
|
||||
dt = new Date(y, m, d, 12);
|
||||
} else {
|
||||
dt = new Date();
|
||||
dt.setFullYear(y);
|
||||
dt.setMonth(m);
|
||||
dt.setDate(d);
|
||||
dt.setHours(0,0,0,0);
|
||||
dt.setHours(12,0,0,0);
|
||||
}
|
||||
return dt;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1056,8 +1056,9 @@ YAHOO.widget.DateMath = {
|
||||
|
||||
/**
|
||||
* Returns a new JavaScript Date object, representing the given year, month and date. Time fields (hr, min, sec, ms) on the new Date object
|
||||
* are set to 0. The method allows Date instances to be created with the a year less than 100. "new Date(year, month, date)" implementations
|
||||
* set the year to 19xx if a year (xx) which is less than 100 is provided.
|
||||
* are set to 0, except the hour which is set to 12 (noon) to avoid issues around the start of Daylight Savings Time. The method allows Date
|
||||
* instances to be created with the a year less than 100. "new Date(year, month, date)" implementations set the year to 19xx if a year (xx)
|
||||
* which is less than 100 is provided.
|
||||
* <p>
|
||||
* <em>NOTE:</em>Validation on argument values is not performed. It is the caller's responsibility to ensure
|
||||
* arguments are valid as per the ECMAScript-262 Date object specification for the new Date(year, month[, date]) constructor.
|
||||
@@ -1074,13 +1075,13 @@ YAHOO.widget.DateMath = {
|
||||
d = 1;
|
||||
}
|
||||
if (y >= 100) {
|
||||
dt = new Date(y, m, d);
|
||||
dt = new Date(y, m, d, 12);
|
||||
} else {
|
||||
dt = new Date();
|
||||
dt.setFullYear(y);
|
||||
dt.setMonth(m);
|
||||
dt.setDate(d);
|
||||
dt.setHours(0,0,0,0);
|
||||
dt.setHours(12,0,0,0);
|
||||
}
|
||||
return dt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user