Chinaunix首页 | 论坛 | 博客
  • 博客访问: 873474
  • 博文数量: 366
  • 博客积分: 10267
  • 博客等级: 上将
  • 技术积分: 4290
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-24 14:04
文章分类

全部博文(366)

文章存档

2012年(366)

分类: 系统运维

2012-04-23 22:03:15

jquery 日历插件fullcalendar

本身是没有农历,因为项目需要添加了农历选择

具体代码

复制代码
1 function RunGLNL(){ 2 var today=new Date(); 3 var d=new Array("周日","周一","周二","周三","周四","周五","周六"); 4 var DDDD= d[today.getDay()]; 5 DDDD = DDDD+ " " + (CnDateofDateStr(today)); //显示农历 6 DDDD = DDDD+SolarTerm(today); //显示二十四节气 7 document.write(DDDD); 8 } 9 function DaysNumberofDate(DateGL){ 10 return parseInt((Date.parse(DateGL)-Date.parse(DateGL.getFullYear()+"/1/1"))/86400000)+1; 11 } 12 function CnDateofDate(DateGL){ 13 var CnData=new Array( 14 0x16,0x2a,0xda,0x00,0x83,0x49,0xb6,0x05,0x0e,0x64,0xbb,0x00,0x19,0xb2,0x5b,0x00, 15 0x87,0x6a,0x57,0x04,0x12,0x75,0x2b,0x00,0x1d,0xb6,0x95,0x00,0x8a,0xad,0x55,0x02, 16 0x15,0x55,0xaa,0x00,0x82,0x55,0x6c,0x07,0x0d,0xc9,0x76,0x00,0x17,0x64,0xb7,0x00, 17 0x86,0xe4,0xae,0x05,0x11,0xea,0x56,0x00,0x1b,0x6d,0x2a,0x00,0x88,0x5a,0xaa,0x04, 18 0x14,0xad,0x55,0x00,0x81,0xaa,0xd5,0x09,0x0b,0x52,0xea,0x00,0x16,0xa9,0x6d,0x00, 19 0x84,0xa9,0x5d,0x06,0x0f,0xd4,0xae,0x00,0x1a,0xea,0x4d,0x00,0x87,0xba,0x55,0x04 20 ); 21 var CnMonth=new Array(); 22 var CnMonthDays=new Array(); 23 var CnBeginDay; 24 var LeapMonth; 25 var Bytes=new Array(); 26 var I; 27 var CnMonthData; 28 var DaysCount; 29 var CnDaysCount; 30 var ResultMonth; 31 var ResultDay; 32 var yyyy=DateGL.getFullYear(); 33 var mm=DateGL.getMonth()+1; 34 var dd=DateGL.getDate(); 35 if(yyyy<100) yyyy+=1900; 36 if ((yyyy < 1997) || (yyyy > 2020)){ 37 return 0; 38 } 39 Bytes[0] = CnData[(yyyy - 1997) * 4]; 40 Bytes[1] = CnData[(yyyy - 1997) * 4 + 1]; 41 Bytes[2] = CnData[(yyyy - 1997) * 4 + 2]; 42 Bytes[3] = CnData[(yyyy - 1997) * 4 + 3]; 43 if ((Bytes[0] & 0x80) != 0) {CnMonth[0] = 12;} 44 else {CnMonth[0] = 11;} 45 CnBeginDay = (Bytes[0] & 0x7f); 46 CnMonthData = Bytes[1]; 47 CnMonthData = CnMonthData << 8; 48 CnMonthData = CnMonthData | Bytes[2]; 49 LeapMonth = Bytes[3]; 50 for (I=15;I>=0;I--){ 51 CnMonthDays[15 - I] = 29; 52 if (((1 << I) & CnMonthData) != 0 ){ 53 CnMonthDays[15 - I]++;} 54 if (CnMonth[15 - I] == LeapMonth ){ 55 CnMonth[15 - I + 1] = - LeapMonth;} 56 else{ 57 if (CnMonth[15 - I] < 0 ){CnMonth[15 - I + 1] = - CnMonth[15 - I] + 1;} 58 else {CnMonth[15 - I + 1] = CnMonth[15 - I] + 1;} 59 if (CnMonth[15 - I + 1] > 12 ){ CnMonth[15 - I + 1] = 1;} 60 } 61 } 62 DaysCount = DaysNumberofDate(DateGL) - 1; 63 if (DaysCount <= (CnMonthDays[0] - CnBeginDay)){ 64 if ((yyyy > 1901) && (CnDateofDate(new Date((yyyy - 1)+"/12/31")) < 0)){ 65 ResultMonth = - CnMonth[0];} 66 else {ResultMonth = CnMonth[0];} 67 ResultDay = CnBeginDay + DaysCount; 68 } 69 else{ 70 CnDaysCount = CnMonthDays[0] - CnBeginDay; 71 I = 1; 72 while ((CnDaysCount < DaysCount) && (CnDaysCount + CnMonthDays[I] < DaysCount)){ 73 CnDaysCount+= CnMonthDays[I]; 74 I++; 75 } 76 ResultMonth = CnMonth[I]; 77 ResultDay = DaysCount - CnDaysCount; 78 } 79 if (ResultMonth > 0){ 80 return ResultMonth * 100 + ResultDay;} 81 else{return ResultMonth * 100 - ResultDay;} 82 } 83 function CnYearofDate(DateGL){ 84 var YYYY=DateGL.getFullYear(); 85 var MM=DateGL.getMonth()+1; 86 var CnMM=parseInt(Math.abs(CnDateofDate(DateGL))/100); 87 if(YYYY<100) YYYY+=1900; 88 if(CnMM>MM) YYYY--; 89 YYYY-=1864; 90 return CnEra(YYYY)+"年"; 91 } 92 function CnMonthofDate(DateGL){ 93 var CnMonthStr=new Array("零","正","二","三","四","五","六","七","八","九","十","冬","腊"); 94 var Month; 95 Month = parseInt(CnDateofDate(DateGL)/100); 96 if (Month < 0){return "闰" + CnMonthStr[-Month] + "月";} 97 else{return CnMonthStr[Month] + "月";} 98 } 99 function CnDayofDate(DateGL){ 100 var CnDayStr=new Array("零", 101 "初一", "初二", "初三", "初四", "初五", 102 "初六", "初七", "初八", "初九", "初十", 103 "十一", "十二", "十三", "十四", "十五", 104 "十六", "十七", "十八", "十九", "二十", 105 "廿一", "廿二", "廿三", "廿四", "廿五", 106 "廿六", "廿七", "廿八", "廿九", "三十"); 107 var Day; 108 Day = (Math.abs(CnDateofDate(DateGL)))%100; 109 //hanlichen mod 110 if("初一"==CnDayStr[Day]){ 111 // alert(SolarTerm(DateGL)); 112 return CnMonthofDate(DateGL); 113 }else{ 114 if(SolarTerm(DateGL)!=""){ 115 return SolarTerm(DateGL); 116 }else 117 { 118 return CnDayStr[Day]; 119 } 120 121 } 122 123 124 } 125 function DaysNumberofMonth(DateGL){ 126 var MM1=DateGL.getFullYear(); 127 MM1<100 ? MM1+=1900:MM1; 128 var MM2=MM1; 129 MM1+="/"+(DateGL.getMonth()+1); 130 MM2+="/"+(DateGL.getMonth()+2); 131 MM1+="/1"; 132 MM2+="/1"; 133 return parseInt((Date.parse(MM2)-Date.parse(MM1))/86400000); 134 } 135 function CnEra(YYYY){ 136 var Tiangan=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸"); 137 //var Dizhi=new Array("子(鼠)","丑(牛)","寅(虎)","卯(兔)","辰(龙)","巳(蛇)", 138 //"午(马)","未(羊)","申(猴)","酉(鸡)","戌(狗)","亥(猪)"); 139 var Dizhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"); 140 return Tiangan[YYYY%10]+Dizhi[YYYY%12]; 141 } 142 function CnDateofDateStr(DateGL){ 143 if(CnMonthofDate(DateGL)=="零月") return " 请调整您的计算机日期!"; 144 else return "农历"+CnYearofDate(DateGL)+ " " + CnMonthofDate(DateGL) + CnDayofDate(DateGL); 145 } 146 function SolarTerm(DateGL){ 147 var SolarTermStr=new Array( 148 "小寒","大寒","立春","雨水","惊蛰","春分", 149 "清明","谷雨","立夏","小满","芒种","夏至", 150 "小暑","大暑","立秋","处暑","白露","秋分", 151 "寒露","霜降","立冬","小雪","大雪","冬至"); 152 var DifferenceInMonth=new Array( 153 1272060,1275495,1281180,1289445,1299225,1310355, 154 1321560,1333035,1342770,1350855,1356420,1359045, 155 1358580,1355055,1348695,1340040,1329630,1318455, 156 1306935,1297380,1286865,1277730,1274550,1271556); 157 var DifferenceInYear=31556926; 158 var BeginTime=new Date(1901/1/1); 159 BeginTime.setTime(947120460000); 160 for(;DateGL.getFullYear()<BeginTime.getFullYear();){ 161 BeginTime.setTime(BeginTime.getTime()-DifferenceInYear*1000); 162 } 163 for(;DateGL.getFullYear()>BeginTime.getFullYear();){ 164 BeginTime.setTime(BeginTime.getTime()+DifferenceInYear*1000); 165 } 166 for(var M=0;DateGL.getMonth()>BeginTime.getMonth();M++){ 167 BeginTime.setTime(BeginTime.getTime()+DifferenceInMonth[M]*1000); 168 } 169 if(DateGL.getDate()>BeginTime.getDate()){ 170 BeginTime.setTime(BeginTime.getTime()+DifferenceInMonth[M]*1000); 171 M++; 172 } 173 if(DateGL.getDate()>BeginTime.getDate()){ 174 BeginTime.setTime(BeginTime.getTime()+DifferenceInMonth[M]*1000); 175 M==23?M=0:M++; 176 } 177 var JQ=""; 178 if(DateGL.getDate()==BeginTime.getDate()){ 179 JQ+=SolarTermStr[M]; 180 } 181 182 return JQ; 183 }
复制代码

这东西不是我写,原文地址我忘记。。。。

有什么对的地方请大家指证

如果神要你孤寂一人,命运要独过一生,你应该怎么宽慰自己?
阅读(2490) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~