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.getDaysInMonth = function(year, month) {
|
||||
Ox.getDaysInMonth = function(year, month, utc) {
|
||||
/*
|
||||
>>> Ox.getDaysInMonth(2000, 2)
|
||||
29
|
||||
>>> Ox.getDaysInMonth("2002", "Feb")
|
||||
28
|
||||
>>> Ox.getDaysInMonth("2004", "February")
|
||||
>>> Ox.getDaysInMonth(new Date('01/01/2004'), "February")
|
||||
29
|
||||
*/
|
||||
var year = parseInt(year),
|
||||
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;
|
||||
|
@ -957,8 +957,16 @@ Ox.getDaysInMonth = function(year, month) {
|
|||
return new Date(year, month, 0).getDate();
|
||||
}
|
||||
|
||||
Ox.getDaysInYear = function(year) {
|
||||
return 365 + Ox.isLeapYear(year);
|
||||
Ox.getDaysInYear = function(year, utc) {
|
||||
/*
|
||||
>>> 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) {
|
||||
|
@ -1060,15 +1068,16 @@ Ox.getWeek = function(date, utc) {
|
|||
Ox.getFirstDayOfTheYear(date, utc) - 1) / 7);
|
||||
};
|
||||
|
||||
Ox.isLeapYear = function(year) {
|
||||
Ox.isLeapYear = function(year, utc) {
|
||||
/*
|
||||
>>> Ox.isLeapYear(1900)
|
||||
false
|
||||
>>> Ox.isLeapYear(2000)
|
||||
>>> Ox.isLeapYear('2000')
|
||||
true
|
||||
>>> Ox.isLeapYear(2004)
|
||||
>>> Ox.isLeapYear(new Date('01/01/2004'))
|
||||
true
|
||||
*/
|
||||
year = Ox.makeYear(year, utc);
|
||||
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
|
||||
};
|
||||
|
||||
|
@ -1077,10 +1086,13 @@ Ox.makeDate = function(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'
|
||||
].forEach(function(noun) {
|
||||
].forEach(function(noun) {
|
||||
Ox['get' + noun] = function(date, utc) {
|
||||
return Ox.makeDate(date)['get' + (utc ? 'UTC' : '') + noun]()
|
||||
}
|
||||
|
@ -1091,10 +1103,9 @@ Ox.makeDate = function(date) {
|
|||
Ox.makeDate(date)
|
||||
)['set' + (utc ? 'UTC' : '') + noun](num);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
DOM functions
|
||||
|
|
Loading…
Reference in a new issue