From 1e71c229395d005b78257de07099d5f3d5c9aadc Mon Sep 17 00:00:00 2001 From: adrianiainlam Date: Mon, 9 May 2016 02:01:11 +0100 Subject: [PATCH] fix issue zzyss86/LunarCalendar#4 author of this fix: cllu () --- lib/LunarCalendar.js | 4 ++-- lib/LunarCalendar.min.js | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 lib/LunarCalendar.min.js diff --git a/lib/LunarCalendar.js b/lib/LunarCalendar.js index f7f06a3..5f38c95 100644 --- a/lib/LunarCalendar.js +++ b/lib/LunarCalendar.js @@ -282,8 +282,8 @@ * 兩個公曆日期之間的天數 */ function getDaysBetweenSolar(year, month, day, year1, month1, day1){ - var date = new Date(year,month,day).getTime(); - var date1 = new Date(year1,month1,day1).getTime(); + var date = Date.UTC(year,month,day); + var date1 = Date.UTC(year1,month1,day1); return (date1-date) / 86400000; }; diff --git a/lib/LunarCalendar.min.js b/lib/LunarCalendar.min.js deleted file mode 100644 index fbda02f..0000000 --- a/lib/LunarCalendar.min.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * 农历(阴历)万年历 - * LunarCalendar;NPM NAME:lunar-calendar - * vervison : v0.1.4 - * Github : https://github.com/zzyss86/LunarCalendar - * HomePage : http://www.tuijs.com/ - * Author : JasonZhou - * Email : zzyss86@qq.com - */ -!function(){function a(a){var b=H[a-B];return b[0]}function b(a){for(var b=H[a-B],c=b[0],d=b[3].toString(2),e=d.split(""),f=0;f<16-e.length;f++)e.unshift(0);for(var g=c?13:12,h=0,i=[],f=0;g>f;f++)0==e[f]?(h+=29,i.push(29)):(h+=30,i.push(30));return{yearDays:h,monthDays:i}}function c(a,c){for(var d=b(a),e=c>0?c:d.yearDays-Math.abs(c),f=d.monthDays,g=0,h=0,i=0;ie){h=i,g-=f[i];break}return[a,h,e-g+1]}function d(a,b,d){var f=H[a-B],g=f[1],h=f[2],i=e(a,g-1,h,a,b,d);if(0==i)return[a,0,1];var j=i>0?a:a-1;return c(j,i)}function e(a,b,c,d,e,f){var g=new Date(a,b,c).getTime(),h=new Date(d,e,f).getTime();return(h-g)/864e5}function f(a,c,d){for(var e=b(a),f=e.monthDays,g=0,h=0;hh;h++)g+=f[h];return g+d-1}function g(a,b){var c=new Date(31556925974.7*(a-1890)+6e4*I[b]+Date.UTC(1890,0,5,16,2,31));return c.getUTCDate()}function h(a){for(var b={},c=0,d=0;24>d;d++){var e=g(a,d);d%2==0&&c++,b[A(c-1,e)]=D.solarTerm[d]}return b}function i(a){var b=a-1890+25;return D.zodiac[b%12]}function j(a){return D.heavenlyStems[a%10]+D.earthlyBranches[a%12]}function k(a,b){return b=b||0,j(a-1890+25+b)}function l(a,b,c){return c=c||0,j(12*(a-1890)+b+12+c)}function m(a,b,c){var d=Date.UTC(a,b,c)/864e5+29219+18;return j(d)}function n(a,b){var c=[31,o(a)?29:28,31,30,31,30,31,31,30,31,30,31];return c[b]}function o(a){return a%4==0&&a%100!=0||a%400==0}function p(a,b,c,d){var e=arguments.length,f=new Date;return a=e?parseInt(a,10):f.getFullYear(),b=e?parseInt(b-1,10):f.getMonth(),c=e?parseInt(c,10)||f.getDate():f.getDate(),(d?d:B+1)>a||a>C?{error:100,msg:x[100]}:{year:a,month:b,day:c}}function q(a,b,c){var d=p(a,b,c);if(d.error)return d;var e=d.year,g=d.month,h=d.day,i=f(e,g,h),j=H[e-B],k=j[1],l=j[2],m=new Date(e,k-1,l).getTime()+864e5*i;return m=new Date(m),{year:m.getFullYear(),month:m.getMonth()+1,day:m.getDate()}}function r(c,e,f){var j=p(c,e,f,B);if(j.error)return j;var n=j.year,o=j.month,q=j.day;z.setCurrent(n);var r=z.get("term2")?z.get("term2"):z.set("term2",g(n,2)),s=z.get("termList")?z.get("termList"):z.set("termList",h(n)),t=g(n,2*o),u=o>1||1==o&&q>=r?n+1:n,v=q>=t?o+1:o,w=d(n,o,q),x=a(w[0]),y="";y=x>0&&x==w[1]?"閏"+D.monthCn[w[1]-1]+"月":x>0&&w[1]>x?D.monthCn[w[1]-1]+"月":D.monthCn[w[1]]+"月";var C="",H=b(w[0]).monthDays;C=w[1]==H.length-1&&w[2]==H[H.length-1]?G.d0100:x>0&&w[1]>x?G[A(w[1]-1,w[2])]:G[A(w[1],w[2])];var I={zodiac:i(u),GanZhiYear:k(u),GanZhiMonth:l(n,v),GanZhiDay:m(n,o,q),worktime:E["y"+n]&&E["y"+n][A(o,q)]?E["y"+n][A(o,q)]:0,term:s[A(o,q)],lunarYear:w[0],lunarMonth:w[1]+1,lunarDay:w[2],lunarMonthName:y,lunarDayName:D.dateCn[w[2]-1],lunarLeapMonth:x,solarFestival:F[A(o,q)],lunarFestival:C};return I}function s(a,b,c){var d=p(a,b);if(d.error)return d;for(var e=d.year,f=d.month,g=t(e,f+1,c),h=0;h0){var l=0>i-1?h-1:h,m=0>i-1?11:i-1;e=n(l,m),f=w(l,m+1,k.firstDay,e-k.firstDay+1),k.monthData=f.concat(k.monthData)}if(42-k.monthData.length!=0){var o=i+1>11?h+1:h,q=i+1>11?0:i+1,r=42-k.monthData.length;g=w(o,q+1,r,1),k.monthData=k.monthData.concat(g)}}return k}function u(a){v(E,a)}var v=function(a,b){if(a&&b&&"object"==typeof b)for(var c in b)a[c]=b[c];return a},w=function(a,b,c,d){var e=[];if(d=d||0,1>c)return e;for(var f=d,g=0;c>g;g++)e.push({year:a,month:b,day:f}),f++;return e},x={100:"輸入的年份超過了可查詢範圍,僅支持1891至2100年",101:"參數輸入錯誤,請查閱文檔"},y=null,z={current:"",setCurrent:function(a){this.current!=a&&(this.current=a,this.clear())},set:function(a,b){return y||(y={}),y[a]=b,y[a]},get:function(a){return y||(y={}),y[a]},clear:function(){y=null}},A=function(a,b){return a+=1,a=10>a?"0"+a:a,b=10>b?"0"+b:b,"d"+a+b},B=1890,C=2100,D={heavenlyStems:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],earthlyBranches:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],zodiac:["鼠","牛","虎","兔","龍","蛇","馬","羊","猴","雞","狗","豬"],solarTerm:["小寒","大寒","立春","雨水","驚蟄","春分","清明","穀雨","立夏","小滿","芒種","夏至","小暑","大暑","立秋","處暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"],monthCn:["正","二","三","四","五","六","七","八","九","十","十一","十二"],dateCn:["初一","初二","初三","初四","初五","初六","初七","初八","初九","初十","十一","十二","十三","十四","十五","十六","十七","十八","十九","二十","廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十","卅一"]},E={};E.y2013={d0101:2,d0102:2,d0103:2,d0105:1,d0106:1,d0209:2,d0210:2,d0211:2,d0212:2,d0213:2,d0214:2,d0215:2,d0216:1,d0217:1,d0404:2,d0405:2,d0406:2,d0407:1,d0427:1,d0428:1,d0429:2,d0430:2,d0501:2,d0608:1," d0609":1,d0610:2,d0611:2,d0612:2,d0919:2,d0920:2,d0921:2,d0922:1,d0929:1,d1001:2,d1002:2,d1003:2,d1004:2,d1005:2,d1006:2,d1007:2,d1012:1},E.y2014={d0101:2,d0126:1,d0131:2,d0201:2,d0202:2,d0203:2,d0204:2,d0205:2,d0206:2,d0208:1,d0405:2,d0407:2,d0501:2,d0502:2,d0503:2,d0504:1,d0602:2,d0908:2,d0928:1,d1001:2,d1002:2,d1003:2,d1004:2,d1005:2," d1006":2,d1007:2,d1011:1};var F={d0101:"元旦節",d0202:"世界濕地日",d0210:"國際氣象節",d0214:"情人節",d0228:"228和平紀念日",d0301:"國際海豹日",d0308:"婦女節",d0312:"植樹節孫中山逝世紀念日",d0314:"國際警察日",d0315:"消費者權益日",d0321:"世界森林日 消除種族歧視國際日 世界兒歌日",d0322:"世界水日",d0323:"世界氣象日",d0324:"世界防治結核病日",d0329:"青年節",d0330:"巴勒斯坦國土日",d0401:"愚人節",d0404:"兒童節",d0407:"世界衛生日",d0422:"世界地球日",d0423:"世界圖書和版權日",d0424:"亞非新聞工作者日",d0501:"勞動節",d0504:"青年節",d0508:"世界紅十字日",d0512:"國際護士節",d0515:"國際家庭日",d0517:"世界電信日",d0518:"國際博物館日",d0520:"全國學生營養日",d0522:"國際生物多樣性日",d0523:"國際牛奶日",d0531:"世界無菸日",d0601:"國際兒童節",d0605:"世界環境日",d0625:"全國土地日",d0626:"國際禁毒日",d0702:"國際體育記者日",d0707:"抗日戰爭紀念日",d0711:"世界人口日",d0730:"非洲婦女日",d0808:"父親節",d0909:"軍人節",d0908:"國際掃盲日國際新聞工作者日",d0914:"世界清潔地球日",d0916:"國際臭氧層保護日",d0920:"國際愛牙日",d0927:"世界旅遊日",d0928:"教師節 孔子誕辰",d1001:"國慶節世界音樂日國際老人節",d1002:"國際和平與民主自由鬥爭日",d1004:"世界動物日",d1008:"全國高血壓日世界視覺日",d1009:"世界郵政日萬國郵聯日",d1010:"國慶日 世界精神衛生日",d1013:"世界保健日國際教師節",d1014:"世界標準日",d1015:"國際盲人節(白手杖節)",d1016:"世界糧食日",d1017:"世界消除貧困日",d1022:"世界傳統醫藥日",d1024:"聯合國日世界發展信息日",d1025:"光復節",d1031:"萬聖節",d1110:"世界青年節",d1111:"國際科學與和平周(本日所屬的一週)",d1112:"孫中山誕辰紀念日",d1114:"世界糖尿病日",d1117:"國際大學生節世界學生節",d1121:"世界問候日世界電視日",d1129:"國際聲援巴勒斯坦人民國際日",d1201:"世界愛滋病日",d1203:"世界殘疾人日",d1205:"國際經濟和社會發展志願人員日",d1208:"國際兒童電視日",d1209:"世界足球日",d1210:"世界人權日",d1221:"國際籃球日",d1224:"平安夜",d1225:"行憲紀念日 聖誕節"},G={d0101:"春節",d0115:"元宵節",d0323:"媽祖生辰",d0505:"端午節",d0707:"七夕情人節",d0715:"中元節",d0815:"中秋節",d0909:"重陽節",d1015:"下元節",d1208:"臘八節",d1223:"小年",d0100:"除夕"},H=[[2,1,21,22184],[0,2,9,21936],[6,1,30,9656],[0,2,17,9584],[0,2,6,21168],[5,1,26,43344],[0,2,13,59728],[0,2,2,27296],[3,1,22,44368],[0,2,10,43856],[8,1,30,19304],[0,2,19,19168],[0,2,8,42352],[5,1,29,21096],[0,2,16,53856],[0,2,4,55632],[4,1,25,27304],[0,2,13,22176],[0,2,2,39632],[2,1,22,19176],[0,2,10,19168],[6,1,30,42200],[0,2,18,42192],[0,2,6,53840],[5,1,26,54568],[0,2,14,46400],[0,2,3,54944],[2,1,23,38608],[0,2,11,38320],[7,2,1,18872],[0,2,20,18800],[0,2,8,42160],[5,1,28,45656],[0,2,16,27216],[0,2,5,27968],[4,1,24,44456],[0,2,13,11104],[0,2,2,38256],[2,1,23,18808],[0,2,10,18800],[6,1,30,25776],[0,2,17,54432],[0,2,6,59984],[5,1,26,27976],[0,2,14,23248],[0,2,4,11104],[3,1,24,37744],[0,2,11,37600],[7,1,31,51560],[0,2,19,51536],[0,2,8,54432],[6,1,27,55888],[0,2,15,46416],[0,2,5,22176],[4,1,25,43736],[0,2,13,9680],[0,2,2,37584],[2,1,22,51544],[0,2,10,43344],[7,1,29,46248],[0,2,17,27808],[0,2,6,46416],[5,1,27,21928],[0,2,14,19872],[0,2,3,42416],[3,1,24,21176],[0,2,12,21168],[8,1,31,43344],[0,2,18,59728],[0,2,8,27296],[6,1,28,44368],[0,2,15,43856],[0,2,5,19296],[4,1,25,42352],[0,2,13,42352],[0,2,2,21088],[3,1,21,59696],[0,2,9,55632],[7,1,30,23208],[0,2,17,22176],[0,2,6,38608],[5,1,27,19176],[0,2,15,19152],[0,2,3,42192],[4,1,23,53864],[0,2,11,53840],[8,1,31,54568],[0,2,18,46400],[0,2,7,46752],[6,1,28,38608],[0,2,16,38320],[0,2,5,18864],[4,1,25,42168],[0,2,13,42160],[10,2,2,45656],[0,2,20,27216],[0,2,9,27968],[6,1,29,44448],[0,2,17,43872],[0,2,6,38256],[5,1,27,18808],[0,2,15,18800],[0,2,4,25776],[3,1,23,27216],[0,2,10,59984],[8,1,31,27432],[0,2,19,23232],[0,2,7,43872],[5,1,28,37736],[0,2,16,37600],[0,2,5,51552],[4,1,24,54440],[0,2,12,54432],[0,2,1,55888],[2,1,22,23208],[0,2,9,22176],[7,1,29,43736],[0,2,18,9680],[0,2,7,37584],[5,1,26,51544],[0,2,14,43344],[0,2,3,46240],[4,1,23,46416],[0,2,10,44368],[9,1,31,21928],[0,2,19,19360],[0,2,8,42416],[6,1,28,21176],[0,2,16,21168],[0,2,5,43312],[4,1,25,29864],[0,2,12,27296],[0,2,1,44368],[2,1,22,19880],[0,2,10,19296],[6,1,29,42352],[0,2,17,42208],[0,2,6,53856],[5,1,26,59696],[0,2,13,54576],[0,2,3,23200],[3,1,23,27472],[0,2,11,38608],[11,1,31,19176],[0,2,19,19152],[0,2,8,42192],[6,1,28,53848],[0,2,15,53840],[0,2,4,54560],[5,1,24,55968],[0,2,12,46496],[0,2,1,22224],[2,1,22,19160],[0,2,10,18864],[7,1,30,42168],[0,2,17,42160],[0,2,6,43600],[5,1,26,46376],[0,2,14,27936],[0,2,2,44448],[3,1,23,21936],[0,2,11,37744],[8,2,1,18808],[0,2,19,18800],[0,2,8,25776],[6,1,28,27216],[0,2,15,59984],[0,2,4,27424],[4,1,24,43872],[0,2,12,43744],[0,2,2,37600],[3,1,21,51568],[0,2,9,51552],[7,1,29,54440],[0,2,17,54432],[0,2,5,55888],[5,1,26,23208],[0,2,14,22176],[0,2,3,42704],[4,1,23,21224],[0,2,11,21200],[8,1,31,43352],[0,2,19,43344],[0,2,7,46240],[6,1,27,46416],[0,2,15,44368],[0,2,5,21920],[4,1,24,42448],[0,2,12,42416],[0,2,2,21168],[3,1,22,43320],[0,2,9,26928],[7,1,29,29336],[0,2,17,27296],[0,2,6,44368],[5,1,26,19880],[0,2,14,19296],[0,2,3,42352],[4,1,24,21104],[0,2,10,53856],[8,1,30,59696],[0,2,18,54560],[0,2,7,55968],[6,1,27,27472],[0,2,15,22224],[0,2,5,19168],[4,1,25,42216],[0,2,12,42192],[0,2,1,53584],[2,1,21,55592],[0,2,9,54560]],I=[0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758],J={solarToLunar:r,lunarToSolar:q,calendar:s,solarCalendar:t,setWorktime:u,getSolarMonthDays:n};"function"==typeof define?define(function(){return J}):"object"==typeof exports?module.exports=J:window.LunarCalendar=J}(); \ No newline at end of file -- 2.7.4