PageSourceSearch

http://www.hiephoidetmay.org.vn/Scripts/Tools/lunar.js

js hiephoidetmay.org.vn collected 2026-10-08 06:05:56 UTC 3,601 bytes, 1 lines download raw bytes

1var PI=Math.PI,_cal={calToLunar:function(b,a){$("#"+b+" .calendar_day").each(function(){var e=Math.floor($(this).attr("d")),f=Math.floor($(this).attr("m")),g=Math.floor($(this).attr("y")),b=_cal.convertSolar2Lunar(e,f,g,a),c="",d="";if(b[1]==1)d="/"+b[2];if(b[0]==1)c="<span class='lunar_firstday'>1/"+b[1]+d+"</span>";else c=b[0];$(this).next().html(c)})},jdFromDate:function(e,f,g){var c,a,d,b;c=Math.floor((14-f)/12);a=g+4800-c;d=f+12*c-3;b=e+Math.floor((153*d+2)/5)+365*a+Math.floor(a/4)-Math.floor(a/100)+Math.floor(a/400)-32045;if(b<2299161)b=e+Math.floor((153*d+2)/5)+365*a+Math.floor(a/4)-32083;return b},jdToDate:function(d){var e,b,c,f,g,a,j,h,i;if(d>2299160){e=d+32044;b=Math.floor((4*e+3)/146097);c=e-Math.floor(b*146097/4)}else{b=0;c=d+32082}f=Math.floor((4*c+3)/1461);g=c-Math.floor(1461*f/4);a=Math.floor((5*g+2)/153);j=g-Math.floor((153*a+2)/5)+1;h=a+3-12*Math.floor(a/10);i=b*100+f-4800+Math.floor(a/10);return[j,h,i]},newMoon:function(i){var c,e,g,a,j,f,d,h,b,k,l;c=i/1236.85;e=c*c;g=e*c;a=PI/180;j=2415020.75933+29.53058868*i+.0001178*e-1.55e-7*g;j=j+.00033*Math.sin((166.56+132.87*c-.009173*e)*a);f=359.2242+29.10535608*i-3.33e-5*e-3.47e-6*g;d=306.0253+385.81691806*i+.0107306*e+1.236e-5*g;h=21.2964+390.67050646*i-.0016528*e-2.39e-6*g;b=(.1734-.000393*c)*Math.sin(f*a)+.0021*Math.sin(2*a*f);b=b-.4068*Math.sin(d*a)+.0161*Math.sin(a*2*d);b=b-4e-4*Math.sin(a*3*d);b=b+.0104*Math.sin(a*2*h)-.0051*Math.sin(a*(f+d));b=b-.0074*Math.sin(a*(f-d))+4e-4*Math.sin(a*(2*h+f));b=b-4e-4*Math.sin(a*(2*h-f))-6e-4*Math.sin(a*(2*h+d));b=b+.001*Math.sin(a*(2*h-d))+5e-4*Math.sin(a*(2*d+f));if(c<-11)k=.001+.000839*c+.0002261*e-8.45e-6*g-8.1e-8*c*g;else k=-.000278+.000265*c+.000262*e;l=j+b-k;return l},sunLongitude:function(h){var a,d,c,f,g,e,b;a=(h-2451545)/36525;d=a*a;c=PI/180;f=357.5291+35999.0503*a-.0001559*d-4.8e-7*a*d;g=280.46645+36000.76983*a+.0003032*d;e=(1.9146-.004817*a-1.4e-5*d)*Math.sin(c*f);e=e+(.019993-.000101*a)*Math.sin(c*2*f)+.00029*Math.sin(c*3*f);b=g+e;b=b*c;b=b-PI*2*Math.floor(b/(PI*2));return b},getSunLongitude:function(a,b){return Math.floor(_cal.sunLongitude(a-.5-b/24)/PI*6)},getNewMoonDay:function(b,a){return Math.floor(_cal.newMoon(b)+.5+a/24)},getLunarMonth11:function(f,b){var c,e,a,d;e=_cal.jdFromDate(31,12,f)-2415021;c=Math.floor(e/29.530588853);a=_cal.getNewMoonDay(c,b);d=_cal.getSunLongitude(a,b);if(d>=9)a=_cal.getNewMoonDay(c-1,b);return a},getLeapMonthOffset:function(f,b){var e,d,c,a;e=Math.floor((f-2415021.0769986948)/29.530588853+.5);d=0;a=1;c=_cal.getSunLongitude(_cal.getNewMoonDay(e+a,b),b);do{d=c;a++;c=_cal.getSunLongitude(_cal.getNewMoonDay(e+a,b),b)}while(c!=d&&a<14);return a-1},convertSolar2Lunar:function(l,m,e,d){var j,f,c,b,i,k,a,g,h;f=_cal.jdFromDate(l,m,e);j=Math.floor((f-2415021.0769986948)/29.530588853);c=_cal.getNewMoonDay(j+1,d);if(c>f)c=_cal.getNewMoonDay(j,d);b=_cal.getLunarMonth11(e,d);i=b;if(b>=c){g=e;b=_cal.getLunarMonth11(e-1,d)}else{g=e+1;i=_cal.getLunarMonth11(e+1,d)}k=f-c+1;diff=Math.floor((c-b)/29);h=0;a=diff+11;if(i-b>365){leapMonthDiff=_cal.getLeapMonthOffset(b,d);if(diff>=leapMonthDiff){a=diff+10;if(diff==leapMonthDiff)h=1}}if(a>12)a=a-12;if(a>=11&&diff<4)g-=1;return[k,a,g,h]},convertLunar2Solar:function(l,f,e,j,a){var k,c,h,b,g,d,i;if(f<11){c=_cal.getLunarMonth11(e-1,a);h=_cal.getLunarMonth11(e,a)}else{c=_cal.getLunarMonth11(e,a);h=_cal.getLunarMonth11(e+1,a)}k=Math.floor(.5+(c-2415021.0769986948)/29.530588853);b=f-11;if(b<0)b+=12;if(h-c>365){g=_cal.getLeapMonthOffset(c,a);d=g-2;if(d<0)d+=12;if(j!=0&&f!=d)return[0,0,0];else if(j!=0||b>=g)b+=1}i=_cal.getNewMoonDay(k+b,a);return _cal.jdToDate(i+l-1)}};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.