* Get the number of days in the current month, adjusted for leap year.
* @return {Number} The number of days in the month
*/
- getDaysInMonth : function() {
+ getDaysInMonth : function()
+ {
Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
return Date.daysInMonth[this.getMonth()];
},
* Get the English ordinal suffix of the current day (equivalent to the format specifier 'S').
* @return {String} 'st, 'nd', 'rd' or 'th'
*/
- getSuffix : function() {
+ getSuffix : function()
+ {
switch (this.getDate()) {
case 1:
case 21:
</code></pre>
* @return {Date} The new Date instance
*/
- clone : function() {
+ clone : function()
+ {
return new Date(this.getTime());
},
@param {Boolean} clone true to create a clone of this date, clear the time and return it
@return {Date} this or the clone
*/
- clearTime : function(clone){
+ clearTime : function(clone)
+ {
if(clone){
return this.clone().clearTime();
}
* @param {Number} value The amount to add to the current date
* @return {Date} The new Date instance
*/
- add : function(interval, value){
- var d = this.clone();
- if (!interval || value === 0) return d;
- switch(interval.toLowerCase()){
- case Date.MILLI:
- d.setMilliseconds(this.getMilliseconds() + value);
- break;
- case Date.SECOND:
- d.setSeconds(this.getSeconds() + value);
- break;
- case Date.MINUTE:
- d.setMinutes(this.getMinutes() + value);
- break;
- case Date.HOUR:
- d.setHours(this.getHours() + value);
- break;
- case Date.DAY:
- d.setDate(this.getDate() + value);
- break;
- case Date.MONTH:
- var day = this.getDate();
- if(day > 28){
- day = Math.min(day, this.getFirstDateOfMonth().add('mo', value).getLastDateOfMonth().getDate());
- }
- d.setDate(day);
- d.setMonth(this.getMonth() + value);
- break;
- case Date.YEAR:
- d.setFullYear(this.getFullYear() + value);
- break;
- }
- return d;
+ add : function(interval, value)
+ {
+ var d = this.clone();
+ if (!interval || value === 0) return d;
+ switch(interval.toLowerCase()){
+ case Date.MILLI:
+ d.setMilliseconds(this.getMilliseconds() + value);
+ break;
+
+ case Date.SECOND:
+ d.setSeconds(this.getSeconds() + value);
+ break;
+
+ case Date.MINUTE:
+ d.setMinutes(this.getMinutes() + value);
+ break;
+
+ case Date.HOUR:
+ d.setHours(this.getHours() + value);
+ break;
+
+ case Date.DAY:
+ d.setDate(this.getDate() + value);
+ break;
+
+ case Date.MONTH:
+ var day = this.getDate();
+ if(day > 28){
+ day = Math.min(day, this.getFirstDateOfMonth().add('mo', value).getLastDateOfMonth().getDate());
+ }
+ d.setDate(day);
+ d.setMonth(this.getMonth() + value);
+ break;
+
+ case Date.YEAR:
+ d.setFullYear(this.getFullYear() + value);
+ break;
+
+ }
+ return d;
}
});
\ No newline at end of file