MDL-32843 import YUI 3.5.1
[moodle.git] / lib / yui / 3.5.1 / build / datatype-date-math / datatype-date-math-min.js
blob8d2bc0cf870e263b993c908cd7c0d7d40d1ac30c
1 /*
2 YUI 3.5.1 (build 22)
3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
6 */
7 YUI.add("datatype-date-math",function(b){var a=b.Lang;b.mix(b.namespace("DataType.Date"),{isValidDate:function(c){if(a.isDate(c)&&(isFinite(c))&&(c!="Invalid Date")&&!isNaN(c)&&(c!=null)){return true;}else{return false;}},areEqual:function(d,c){return(this.isValidDate(d)&&this.isValidDate(c)&&(d.getTime()==c.getTime()));},isGreater:function(d,c){return(this.isValidDate(d)&&this.isValidDate(c)&&(d.getTime()>c.getTime()));},isGreaterOrEqual:function(d,c){return(this.isValidDate(d)&&this.isValidDate(c)&&(d.getTime()>=c.getTime()));},isInRange:function(e,d,c){return(this.isGreaterOrEqual(e,d)&&this.isGreaterOrEqual(c,e));},addDays:function(d,c){return new Date(d.getTime()+86400000*c);},addMonths:function(f,c){var e=f.getFullYear();var g=f.getMonth()+c;e=Math.floor(e+g/12);g=(g%12+12)%12;var d=new Date(f.getTime());d.setYear(e);d.setMonth(g);return d;},addYears:function(f,e){var d=f.getFullYear()+e;var c=new Date(f.getTime());c.setYear(d);return c;},listOfDatesInMonth:function(g){if(!this.isValidDate(g)){return[];}var e=this.daysInMonth(g),f=g.getFullYear(),h=g.getMonth(),d=[];for(var c=1;c<=e;c++){d.push(new Date(f,h,c,12,0,0));}return d;},daysInMonth:function(e){if(!this.isValidDate(e)){return 0;}var d=e.getMonth();var f=[31,28,31,30,31,30,31,31,30,31,30,31];if(d!=1){return f[d];}else{var c=e.getFullYear();if(c%400===0){return 29;}else{if(c%100===0){return 28;}else{if(c%4===0){return 29;}else{return 28;}}}}}});},"3.5.1",{requires:["yui-base"]});