Merge pull request #378 from tcmug/weekofyear

Add a callback for getWeekOfYear command, onGetWeekOfYear.
This commit is contained in:
Valeriy 2016-01-22 10:50:23 +05:00
commit 68dc8005f5

View File

@ -556,6 +556,7 @@
onSelectDate: function () {},
onSelectTime: function () {},
onChangeMonth: function () {},
onGetWeekOfYear: function () {},
onChangeYear: function () {},
onChangeDateTime: function () {},
onShow: function () {},
@ -1445,6 +1446,12 @@
};
_this.getWeekOfYear = function (datetime) {
if (options.onGetWeekOfYear && $.isFunction(options.onGetWeekOfYear)) {
var week = options.onGetWeekOfYear.call(datetimepicker, datetime);
if (typeof week !== 'undefined') {
return week;
}
}
var onejan = new Date(datetime.getFullYear(), 0, 1);
return Math.ceil((((datetime - onejan) / 86400000) + onejan.getDay() + 1) / 7);
};