Resolution for bug in ShowWeekNumber option of datepicker
Resolution for bug in ShowWeekNumber option of datepicker
ShowWeekNumbers gives the wrong weeknumber.
Week of the year according to ISO 8601 standard first week of the year is the week of the first Thursday of a year.
If you want to patch this: override _htmlWeekOfYear function in dataTables.editor.min.js
, _htmlWeekOfYear: function (a, b, c) {
var d = new Date(c, b, a);
d.setHours(0, 0, 0);
// Make Sunday's day number 7
var dayNo = (d.getDay() || 7);
// Set to nearest Thursday: current date + 4 - current day number
d.setDate(d.getDate() + 4 - dayNo);
// Get first day of year
var yearStart = new Date(d.getFullYear(), 0, 1);
// Calculate full weeks to nearest Thursday
var weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
return '<td class="' + this.c.classPrefix + '-week">' + weekNo + '</td>';
}
This discussion has been closed.
Answers
Thanks for posting this!
I'll look over this in detail and get it into the next release of Editor. I'll post back here when done.
Allan
you're welcome!
+1
Somewhat delayed reply I'm afraid, but the correct calculation for the ISO8601 week number will be included in Editor 1.6.
Regards,
Allan