I have some problem with Date.js library. I use the russian culture settings. First day of week is setted by 1. And it means, that my week should be since Monday till Sunday. Monday should be the return vaue when i call: Date.getDayNumberFromName('понедельник'); //Monday, it should return 0 and Date.getDayNumberFromName('воскресенье'); //Sunday, it should return 6
and, of course, it should be actual to all weeks calculations. For example, today (Sunday, 3 March), this code: Date.monday(), should return 25 February. But it isn't so. Why? What should i do, to change global "firstDayOfWeek"?
Update: There are some problems with fiddle. I've made example on my own host: http://sulla.ru/lab/
I made debug of this almost dead library (dead, because last update was about 4 years ago) and i found bug. The sdf function, which calculates shift, is so:
var sdf = function (n) {
return function () {
var t = $D.today(), shift = n - t.getDay();
if (n === 0 && $C.firstDayOfWeek === 1 && t.getDay() !== 0) {
shift = shift + 7;
}
return t.addDays(shift);
};
};
and i've changed it to:
var sdf = function (n) {
return function () {
var t = $D.today(), shift = n - t.getDay();
if (n === 0 && $C.firstDayOfWeek === 1 && t.getDay() !== 0) {
shift = shift + 7;
} else if (t.getDay() === 0 && n !== 0) {
shift = shift - 7;
}
return t.addDays(shift);
};
};
Obviously, it solves my problem. I've made bug ticket with this problem, and sent the answer.