cleanup
This commit is contained in:
parent
3672d7ee9c
commit
dc1ec954fb
1 changed files with 39 additions and 28 deletions
|
@ -940,16 +940,16 @@ Ox.getDayOfTheYear = function(date, utc) {
|
||||||
})) + Ox.getDate(date, utc);
|
})) + Ox.getDate(date, utc);
|
||||||
};
|
};
|
||||||
|
|
||||||
Ox.getDaysInMonth = function(year, month) {
|
Ox.getDaysInMonth = function(year, month, utc) {
|
||||||
/*
|
/*
|
||||||
>>> Ox.getDaysInMonth(2000, 2)
|
>>> Ox.getDaysInMonth(2000, 2)
|
||||||
29
|
29
|
||||||
>>> Ox.getDaysInMonth("2002", "Feb")
|
>>> Ox.getDaysInMonth("2002", "Feb")
|
||||||
28
|
28
|
||||||
>>> Ox.getDaysInMonth("2004", "February")
|
>>> Ox.getDaysInMonth(new Date('01/01/2004'), "February")
|
||||||
29
|
29
|
||||||
*/
|
*/
|
||||||
var year = parseInt(year),
|
year = Ox.makeYear(year);
|
||||||
month = Ox.isNumber(month) ? month :
|
month = Ox.isNumber(month) ? month :
|
||||||
Ox.map(Ox.MONTHS, function(v, i) {
|
Ox.map(Ox.MONTHS, function(v, i) {
|
||||||
return v.substr(0, 3) == month.substr(0, 3) ? i + 1 : null;
|
return v.substr(0, 3) == month.substr(0, 3) ? i + 1 : null;
|
||||||
|
@ -957,8 +957,16 @@ Ox.getDaysInMonth = function(year, month) {
|
||||||
return new Date(year, month, 0).getDate();
|
return new Date(year, month, 0).getDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ox.getDaysInYear = function(year) {
|
Ox.getDaysInYear = function(year, utc) {
|
||||||
return 365 + Ox.isLeapYear(year);
|
/*
|
||||||
|
>>> Ox.getDaysInYear(1900)
|
||||||
|
365
|
||||||
|
>>> Ox.getDaysInYear('2000')
|
||||||
|
366
|
||||||
|
>>> Ox.getDaysInYear(new Date('01/01/2004'))
|
||||||
|
366
|
||||||
|
*/
|
||||||
|
return 365 + Ox.isLeapYear(Ox.makeYear(year, utc));
|
||||||
};
|
};
|
||||||
|
|
||||||
Ox.getFirstDayOfTheYear = function(date, utc) {
|
Ox.getFirstDayOfTheYear = function(date, utc) {
|
||||||
|
@ -1060,15 +1068,16 @@ Ox.getWeek = function(date, utc) {
|
||||||
Ox.getFirstDayOfTheYear(date, utc) - 1) / 7);
|
Ox.getFirstDayOfTheYear(date, utc) - 1) / 7);
|
||||||
};
|
};
|
||||||
|
|
||||||
Ox.isLeapYear = function(year) {
|
Ox.isLeapYear = function(year, utc) {
|
||||||
/*
|
/*
|
||||||
>>> Ox.isLeapYear(1900)
|
>>> Ox.isLeapYear(1900)
|
||||||
false
|
false
|
||||||
>>> Ox.isLeapYear(2000)
|
>>> Ox.isLeapYear('2000')
|
||||||
true
|
true
|
||||||
>>> Ox.isLeapYear(2004)
|
>>> Ox.isLeapYear(new Date('01/01/2004'))
|
||||||
true
|
true
|
||||||
*/
|
*/
|
||||||
|
year = Ox.makeYear(year, utc);
|
||||||
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
|
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1077,7 +1086,10 @@ Ox.makeDate = function(date) {
|
||||||
Ox.isUndefined(date) ? new Date() : new Date(date);
|
Ox.isUndefined(date) ? new Date() : new Date(date);
|
||||||
};
|
};
|
||||||
|
|
||||||
['get', 'set'].forEach(function(verb) {
|
Ox.makeYear = function(date, utc) {
|
||||||
|
return Ox.isDate(date) ? Ox.getFullYear(date, utc) : parseInt(date);
|
||||||
|
};
|
||||||
|
|
||||||
[
|
[
|
||||||
'FullYear', 'Month', 'Date', 'Day', 'Hours', 'Minutes', 'Seconds'
|
'FullYear', 'Month', 'Date', 'Day', 'Hours', 'Minutes', 'Seconds'
|
||||||
].forEach(function(noun) {
|
].forEach(function(noun) {
|
||||||
|
@ -1093,7 +1105,6 @@ Ox.makeDate = function(date) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
Loading…
Reference in a new issue