1
0
Fork 0
forked from 0x2620/oxjs

less obscure Ox.map

This commit is contained in:
rolux 2012-05-22 16:29:37 +02:00
commit 12cf77cef5
21 changed files with 125 additions and 101 deletions

View file

@ -25,9 +25,9 @@ Ox.getDateInWeek = function(date, weekday, utc) {
date = Ox.makeDate(date);
var sourceWeekday = Ox.getISODay(date, utc),
targetWeekday = Ox.isNumber(weekday) ? weekday
: Ox.map(Ox.WEEKDAYS, function(v, i) {
return v.substr(0, 3) == weekday.substr(0, 3) ? i + 1 : null;
})[0];
: Ox.indexOf(Ox.WEEKDAYS, function(v) {
return v.substr(0, 3) == weekday.substr(0, 3);
}) + 1;
return Ox.setDate(date, Ox.getDate(date, utc) - sourceWeekday + targetWeekday, utc);
}
@ -71,9 +71,9 @@ Ox.getDaysInMonth <f> Get the number of days in a given month
Ox.getDaysInMonth = function(year, month) {
year = Ox.makeYear(year);
month = Ox.isNumber(month) ? month
: Ox.map(Ox.MONTHS, function(v, i) {
return v.substr(0, 3) == month.substr(0, 3) ? i + 1 : null;
})[0];
: Ox.getIndexOf(Ox.MONTHS, function(v) {
return v.substr(0, 3) == month.substr(0, 3);
}) + 1;
return new Date(year, month, 0).getDate();
}