This value is not what it says:
SECONDS_IN_DAY = 86400000,
That's the number of milliseconds in a day. Instead of a magic precalculated number, why not create all the relevant constants so the values become perfectly clear: HOURS_IN_DAY = 24,
MINUTES_IN_DAY = HOURS_IN_DAY * 60,
SECONDS_IN_DAY = MINUTES_IN_DAY * 60,
MILLISECONDS_IN_DAY = SECONDS_IN_DAY * 1000,
Personally, I find these kinds of string constants get in the way: STRING_DIV = 'div',
STRING_TR = 'tr',
The string 'div' is never going to change to something else, is it? It would be better to just use the string directly where you need it.This is an amazing and scary piece of code:
/**
* Get the count of the number of
* days in a month, given the
* month and year
*/
getCountDays = function( year, month ) {
var
// Set flip based on if month is
// before or after July
flip = ( month > 6 ) ? true : false
// If it's February
if ( month === 1 ) {
// If it's not a leap year
// then 28 otherwise 29
return ( year % 4 ) ? 28 : 29
}
// If it's an odd month ID
if ( month % 2 ) {
// If it's after July then 31
// otherwise 30
return ( flip ) ? 31 : 30
}
// If it's an even month ID
// and it's after July then 30
// otherwise 31
return ( flip ) ? 30 : 31
}, //getCountDays
It also calculates leap years incorrectly - try getCountDays(1900,1). February 1900 had 28 days, not 29.Why not let JavaScript do the work for you?
getCountDays = function( year, month ) {
var msInMonth = new Date(year,month+1) - new Date(year,month);
return Math.floor( msInMonth / MILLISECONDS_IN_DAY );
},
This will handle all leap years correctly.You can probably do something similar in your createDate function to avoid the manual tests.
Also the name getCountDays is not very informative. Maybe getDaysInMonth?
The settings options use names_with_underscores, but that's not very idiomatic in JavaScript (except for capitalized constants). camelCaseNames would be more comfortable.