//>>built
define("dojox/date/persian/Date",["dojo/_base/lang","dojo/_base/declare","dojo/date"],function(l,k,m){var h=k("dojox.date.persian.Date",null,{_date:0,_month:0,_year:0,_hours:0,_minutes:0,_seconds:0,_milliseconds:0,_day:0,_GREGORIAN_EPOCH:1721425.5,_PERSIAN_EPOCH:1948320.5,daysInMonth:[31,31,31,31,31,31,30,30,30,30,30,29],constructor:function(){var a=arguments.length;a?1==a?(a=arguments[0],"number"==typeof a&&(a=new Date(a)),a instanceof Date?this.fromGregorian(a):""==a?this._date=new Date(""):(this._year=
a._year,this._month=a._month,this._date=a._date,this._hours=a._hours,this._minutes=a._minutes,this._seconds=a._seconds,this._milliseconds=a._milliseconds)):3<=a&&(this._year+=arguments[0],this._month+=arguments[1],this._date+=arguments[2],this._hours+=arguments[3]||0,this._minutes+=arguments[4]||0,this._seconds+=arguments[5]||0,this._milliseconds+=arguments[6]||0):this.fromGregorian(new Date)},getDate:function(){return this._date},getMonth:function(){return this._month},getFullYear:function(){return this._year},
getDay:function(){return this.toGregorian().getDay()},getHours:function(){return this._hours},getMinutes:function(){return this._minutes},getSeconds:function(){return this._seconds},getMilliseconds:function(){return this._milliseconds},setDate:function(a){a=parseInt(a);if(!(0<a&&a<=this.getDaysInPersianMonth(this._month,this._year))){var b;if(0<a)for(b=this.getDaysInPersianMonth(this._month,this._year);a>b;a-=b,b=this.getDaysInPersianMonth(this._month,this._year))this._month++,12<=this._month&&(this._year++,
this._month-=12);else for(b=this.getDaysInPersianMonth(0<=this._month-1?this._month-1:11,0<=this._month-1?this._year:this._year-1);0>=a;b=this.getDaysInPersianMonth(0<=this._month-1?this._month-1:11,0<=this._month-1?this._year:this._year-1))this._month--,0>this._month&&(this._year--,this._month+=12),a+=b}this._date=a;return this},setFullYear:function(a){this._year=+a},setMonth:function(a){this._year+=Math.floor(a/12);this._month=0<a?Math.floor(a%12):Math.floor((a%12+12)%12)},setHours:function(){var a=
arguments.length,b=0;1<=a&&(b=parseInt(arguments[0]));2<=a&&(this._minutes=parseInt(arguments[1]));3<=a&&(this._seconds=parseInt(arguments[2]));4==a&&(this._milliseconds=parseInt(arguments[3]));for(;24<=b;)this._date++,a=this.getDaysInPersianMonth(this._month,this._year),this._date>a&&(this._month++,12<=this._month&&(this._year++,this._month-=12),this._date-=a),b-=24;this._hours=b},_addMinutes:function(a){a+=this._minutes;this.setMinutes(a);this.setHours(this._hours+parseInt(a/60));return this},_addSeconds:function(a){a+=
this._seconds;this.setSeconds(a);this._addMinutes(parseInt(a/60));return this},_addMilliseconds:function(a){a+=this._milliseconds;this.setMilliseconds(a);this._addSeconds(parseInt(a/1E3));return this},setMinutes:function(a){this._minutes=a%60;return this},setSeconds:function(a){this._seconds=a%60;return this},setMilliseconds:function(a){this._milliseconds=a%1E3;return this},toString:function(){if(isNaN(this._date))return"Invalidate Date";var a=new Date;a.setHours(this._hours);a.setMinutes(this._minutes);
a.setSeconds(this._seconds);a.setMilliseconds(this._milliseconds);return this._month+" "+this._date+" "+this._year+" "+a.toTimeString()},toGregorian:function(){var a=this.persian_to_jd(this._year,this._month+1,this._date);var b=this.jd_to_gregorian(a,this._month+1);weekday=this.jwday(a);return new Date(b[0],b[1]-1,b[2],this._hours,this._minutes,this._seconds,this._milliseconds)},fromGregorian:function(a){a=new Date(a);var b=a.getFullYear(),c=a.getMonth(),d=a.getDate();b=this.calcGregorian(b,c,d);
this._date=b[2];this._month=b[1];this._year=b[0];this._hours=a.getHours();this._minutes=a.getMinutes();this._seconds=a.getSeconds();this._milliseconds=a.getMilliseconds();this._day=a.getDay();return this},calcGregorian:function(a,b,c){a=this.gregorian_to_jd(a,b+1,c)+0;perscal=this.jd_to_persian(a);a=this.jwday(a);return[perscal[0],perscal[1],perscal[2],a]},jd_to_persian:function(a){a=Math.floor(a)+.5;var b=a-this.persian_to_jd(475,1,1);var c=Math.floor(b/1029983);var d=this._mod(b,1029983);1029982==
d?b=2820:(b=Math.floor(d/366),d=this._mod(d,366),b=Math.floor((2134*b+2816*d+2815)/1028522)+b+1);c=b+2820*c+474;0>=c&&c--;b=a-this.persian_to_jd(c,1,1)+1;b=186>=b?Math.ceil(b/31):Math.ceil((b-6)/30);a=a-this.persian_to_jd(c,b,1)+1;return[c,b-1,a]},persian_to_jd:function(a,b,c){a-=0<=a?474:473;var d=474+this._mod(a,2820);return c+(7>=b?31*(b-1):30*(b-1)+6)+Math.floor((682*d-110)/2816)+365*(d-1)+1029983*Math.floor(a/2820)+(this._PERSIAN_EPOCH-1)},gregorian_to_jd:function(a,b,c){return this._GREGORIAN_EPOCH-
1+365*(a-1)+Math.floor((a-1)/4)+-Math.floor((a-1)/100)+Math.floor((a-1)/400)+Math.floor((367*b-362)/12+(2>=b?0:this.leap_gregorian(a)?-1:-2)+c)},jd_to_gregorian:function(a,b){var c=Math.floor(a-.5)+.5;var d=c-this._GREGORIAN_EPOCH;var e=Math.floor(d/146097);var g=this._mod(d,146097);d=Math.floor(g/36524);var f=this._mod(g,36524);g=Math.floor(f/1461);f=this._mod(f,1461);f=Math.floor(f/365);e=400*e+100*d+4*g+f;4!=d&&4!=f&&e++;d=c-this.gregorian_to_jd(e,1,1);g=c<this.gregorian_to_jd(e,3,1)?0:this.leap_gregorian(e)?
1:2;month=Math.floor((12*(d+g)+373)/367);day=c-this.gregorian_to_jd(e,month,1)+1;return[e,month,day]},valueOf:function(){return this.toGregorian().valueOf()},jwday:function(a){return this._mod(Math.floor(a+1.5),7)},_yearStart:function(a){return 354*(a-1)+Math.floor((3+11*a)/30)},_monthStart:function(a,b){return Math.ceil(29.5*b)+354*(a-1)+Math.floor((3+11*a)/30)},leap_gregorian:function(a){return 0==a%4&&!(0==a%100&&0!=a%400)},isLeapYear:function(a,b,c){return!(0>a||32767<a||1>b||12<b||1>c||c>this.daysInMonth[b-
1]+(12==b&&!((a-979)%33%4)))},getDaysInPersianMonth:function(a,b){var c=this.daysInMonth[a];11==a&&this.isLeapYear(b,a+1,30)&&c++;return c},_mod:function(a,b){return a-b*Math.floor(a/b)}});h.getDaysInPersianMonth=function(a){return(new h).getDaysInPersianMonth(a.getMonth(),a.getFullYear())};return h});