e5d53905535e5ca49231eb485287ab25275c56e8
[platform/framework/web/crosswalk-tizen.git] /
1 var isDate = require('../lang/isDate');
2 var isLeapYear = require('./isLeapYear');
3
4     var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
5
6     /**
7      * returns the total amount of days in the month (considering leap years)
8      */
9     function totalDaysInMonth(fullYear, monthIndex){
10         if (isDate(fullYear)) {
11             monthIndex = fullYear.getMonth();
12         }
13
14         if (monthIndex === 1 && isLeapYear(fullYear)) {
15             return 29;
16         } else {
17             return DAYS_IN_MONTH[monthIndex];
18         }
19     }
20
21     module.exports = totalDaysInMonth;
22
23