//>>built
define("demos/sunMap/src/Sun",["dojo/_base/kernel","dojo/_base/declare"],function(_1,_2){return _2(null,{_now:false,constructor:function(d){if(!d){d=new Date();}this._date=d;},getDate:function(){var d=this._date;if(d==null){d=new Date();this._date=d;}return d;},setDate:function(d){if(!d){d=new Date();}this._date=d;},isNow:function(){return this._now;},clip:function(p,c){if(p.x<c.x1){p.x=c.x1;}if(p.y<c.y2){p.y=c.y2;}if(p.x>c.x2){p.x=c.x2;}if(p.y>c.y1){p.y=c.y1;}return p;},twilightZone:function(c){var _3=[];clip=function(p,c){if(p.x<c.x1){p.x=c.x1;}if(p.y<c.y2){p.y=c.y2;}if(p.x>c.x2){p.x=c.x2;}if(p.y>c.y1){p.y=c.y1;}return p;};addPoint=function(p){if(c){p=this.clip(p,c);}_3.push(p);};sLon=-180;sLat=-90;eLon=180;eLat=90;if(c){if(sLon<c.x1){sLon=c.x1;}if(sLat<c.y2){sLat=c.y2;}if(eLon>c.x2){eLon=c.x2;}if(eLat>c.y1){eLat=c.y1;}}var dt=this.getDate();var LT=dt.getUTCHours()+dt.getUTCMinutes()/60+dt.getUTCSeconds()/3600;var _4=15*(LT-12);var o=this.sunDecRa();var _5=o.dec;var _6=1;var _7=Math.PI/180;for(var i=sLon;i<=eLon;i+=_6){var _8=i+_4;var _9=-Math.cos(_8*_7)/Math.tan(_5*_7);var _a=Math.atan(_9)/_7;addPoint({x:i,y:_a});}if(_5<0){addPoint({x:180,y:-85});addPoint({x:-180,y:-85});addPoint({x:_3[0].x,y:_3[0].y});}else{addPoint({x:180,y:85});addPoint({x:-180,y:85});}return _3;},sun:function(){var o=this.sunDecRa();var _b=o.dec;var dt=this.getDate();var LT=dt.getUTCHours()+dt.getUTCMinutes()/60+dt.getUTCSeconds()/3600;var _c=15*(LT-12);var et=0;var p={x:-_c+et,y:_b};return p;},jd:function(_d){var dt;if(_d!=null){dt=_d;}else{dt=this.getDate();}MM=dt.getMonth()+1;DD=dt.getDate();YY=dt.getFullYear();HR=dt.getUTCHours();MN=dt.getUTCMinutes();SC=0;with(Math){HR=HR+(MN/60)+(SC/3600);GGG=1;if(YY<=1585){GGG=0;}JD=-1*floor(7*(floor((MM+9)/12)+YY)/4);S=1;if((MM-9)<0){S=-1;}A=abs(MM-9);J1=floor(YY+S*floor(A/7));J1=-1*floor((floor(J1/100)+1)*3/4);JD=JD+floor(275*MM/9)+DD+(GGG*J1);JD=JD+1721027+2*GGG+367*YY-0.5;JD=JD+(HR/24);}return JD;},sunDecRa:function(){var jd=this.jd();var _e=2*Math.PI;var _f=0.917482;var _10=0.397778;var M,DL,L,SL,X,Y,Z,R;var T,dec,ra;T=(jd-2451545)/36525;M=_e*this.frac(0.993133+99.997361*T);DL=6893*Math.sin(M)+72*Math.sin(2*M);L=_e*this.frac(0.7859453+M/_e+(6191.2*T+DL)/1296000);SL=Math.sin(L);X=Math.cos(L);Y=_f*SL;Z=_10*SL;R=Math.sqrt(1-Z*Z);dec=(360/_e)*Math.atan(Z/R);ra=(48/_e)*Math.atan(Y/(X+R));if(ra<0){ra=ra+24;}return {dec:dec,ra:ra};},et:function(d){if(!d){d=this.getDate();}var _11=date.getUTCFullYear();var _12=date.getUTCMonth()+1;var day=date.getUTCDate();var N1=Math.floor((_12*275)/9);var N2=Math.floor((_12+9)/12);var K=1+Math.floor((_11-4*Math.floor(_11/4)+2)/3);var j=N1-N2*K+day-30;var M=357+0.9856*j;var C=1.914*Math.sin(M)+0.02*Math.sin(2*M);var L=280+C+0.9856*j;var R=-2.465*Math.sin(2*L)+0.053*Math.sin(4*L);var ET=(C+R)*4;return ET;},frac:function(x){x=x-Math.floor(x);if(x<0){x=x+1;}return x;}});});