document.writeln("<script language=\"JavaScript\">");
document.writeln("function CalConv()");
document.writeln("{");
document.writeln("FIRSTYEAR = 1998;");
document.writeln("LASTYEAR = 2031;");
document.writeln("");
document.writeln("today = new Date();");
document.writeln("SolarYear = today.getFullYear();");
document.writeln("SolarMonth = today.getMonth() + 1;");
document.writeln("SolarDate = today.getDate();");
document.writeln("Weekday = today.getDay();");
document.writeln("LunarCal = [");
document.writeln("new tagLunarCal( 27, 5, 3, 43, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ),");
document.writeln("new tagLunarCal( 46, 0, 4, 48, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ), \/* 88 *\/");
document.writeln("new tagLunarCal( 35, 0, 5, 53, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 ), \/* 89 *\/");
document.writeln("new tagLunarCal( 23, 4, 0, 59, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),");
document.writeln("new tagLunarCal( 42, 0, 1, 4, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),");
document.writeln("new tagLunarCal( 31, 0, 2, 9, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0 ),");
document.writeln("new tagLunarCal( 21, 2, 3, 14, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), \/* 93 *\/");
document.writeln("new tagLunarCal( 39, 0, 5, 20, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ),");
document.writeln("new tagLunarCal( 28, 7, 6, 25, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ),");
document.writeln("new tagLunarCal( 48, 0, 0, 30, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ),");
document.writeln("new tagLunarCal( 37, 0, 1, 35, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ), \/* 97 *\/");
document.writeln("new tagLunarCal( 25, 5, 3, 41, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),");
document.writeln("new tagLunarCal( 44, 0, 4, 46, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),");
document.writeln("new tagLunarCal( 33, 0, 5, 51, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),");
document.writeln("new tagLunarCal( 22, 4, 6, 56, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), \/* 101 *\/");
document.writeln("new tagLunarCal( 40, 0, 1, 2, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ),");
document.writeln("new tagLunarCal( 30, 9, 2, 7, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),");
document.writeln("new tagLunarCal( 49, 0, 3, 12, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1 ),");
document.writeln("new tagLunarCal( 38, 0, 4, 17, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 ), \/* 105 *\/");
document.writeln("new tagLunarCal( 27, 6, 6, 23, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ),");
document.writeln("new tagLunarCal( 46, 0, 0, 28, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0 ),");
document.writeln("new tagLunarCal( 35, 0, 1, 33, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ),");
document.writeln("new tagLunarCal( 24, 4, 2, 38, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), \/* 109 *\/");
document.writeln("new tagLunarCal( 42, 0, 4, 44, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ),");
document.writeln("new tagLunarCal( 31, 0, 5, 49, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 ),");
document.writeln("new tagLunarCal( 21, 2, 6, 54, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),");
document.writeln("new tagLunarCal( 40, 0, 0, 59, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), \/* 113 *\/");
document.writeln("new tagLunarCal( 28, 6, 2, 5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ),");
document.writeln("new tagLunarCal( 47, 0, 3, 10, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1 ),");
document.writeln("new tagLunarCal( 36, 0, 4, 15, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ),");
document.writeln("new tagLunarCal( 25, 5, 5, 20, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ), \/* 117 *\/");
document.writeln("new tagLunarCal( 43, 0, 0, 26, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ),");
document.writeln("new tagLunarCal( 32, 0, 1, 31, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0 ),");
document.writeln("new tagLunarCal( 22, 3, 2, 36, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 ) ];");
document.writeln("SolarCal = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];");
document.writeln("SolarDays = [ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396, 0, 31, 60, 91, ");
document.writeln("121, 152, 182, 213, 244, 274, 305, 335, 366, 397 ];");
document.writeln("AnimalIdx = [\"马\", \"羊\", \"猴\", \"鸡\", \"狗\", \"猪\", \"鼠\", \"牛\", \"虎\", \"兔\", \"龙\", \"蛇\" ];");
document.writeln("LocationIdx = [ \"南\", \"东\", \"北\", \"西\" ];");
document.writeln("if ( SolarYear <= FIRSTYEAR || SolarYear > LASTYEAR ) return 1;");
document.writeln("sm = SolarMonth - 1;");
document.writeln("if ( sm < 0 || sm > 11 ) return 2;");
document.writeln("leap = GetLeap( SolarYear );");
document.writeln("if ( sm == 1 )");
document.writeln("d = leap + 28;");
document.writeln("else");
document.writeln("d = SolarCal[sm];");
document.writeln("if ( SolarDate < 1 || SolarDate > d ) return 3;");
document.writeln("y = SolarYear - FIRSTYEAR;");
document.writeln("acc = SolarDays[ leap*14 + sm ] + SolarDate;");
document.writeln("kc = acc + LunarCal[y].BaseKanChih;");
document.writeln("Kan = kc % 10;");
document.writeln("Chih = kc % 12;");
document.writeln("Location = LocationIdx[kc % 4];");
document.writeln("Age = kc % 60;");
document.writeln("if ( Age < 22 )");
document.writeln("Age = 22 - Age;");
document.writeln("else");
document.writeln("Age = 82 - Age;");
document.writeln("Animal = AnimalIdx[ Chih ];");
document.writeln("if ( acc <= LunarCal[y].BaseDays ) {");
document.writeln("y--;");
document.writeln("LunarYear = SolarYear - 1;");
document.writeln("leap = GetLeap( LunarYear );");
document.writeln("sm += 12;");
document.writeln("acc = SolarDays[leap*14 + sm] + SolarDate;");
document.writeln("}");
document.writeln("else");
document.writeln("LunarYear = SolarYear;");
document.writeln("l1 = LunarCal[y].BaseDays;");
document.writeln("for ( i=0; i<13; i++ ) {");
document.writeln("l2 = l1 + LunarCal[y].MonthDays[i] + 29;");
document.writeln("if ( acc <= l2 ) break;");
document.writeln("l1 = l2;");
document.writeln("}");
document.writeln("LunarMonth = i + 1;");
document.writeln("LunarDate = acc - l1;");
document.writeln("im = LunarCal[y].Intercalation;");
document.writeln("if ( im != 0 && LunarMonth > im ) {");
document.writeln("LunarMonth--;");
document.writeln("if ( LunarMonth == im ) LunarMonth = -im;");
document.writeln("}");
document.writeln("if ( LunarMonth > 12 ) LunarMonth -= 12;");
document.writeln("today=new Date();");
document.writeln("function initArray(){");
document.writeln("this.length=initArray.arguments.length");
document.writeln("for(var i=0;i<this.length;i++)");
document.writeln("this[i+1]=initArray.arguments[i] }");
document.writeln("var d=new initArray(\"星期日\",\"星期一\",\"星期二\",\"星期三\",\"星期四\",\"星期五\",\"星期六\");");
document.writeln("document.write( today.getYear(),\"年\",today.getMonth() ");
document.writeln("+1,\"月\",today.getDate(),\"日\",d[today.getDay()+1]);" );
document.writeln("document.write( \"农历\"+LunarMonth +\"月\"+LunarDate +" );
document.writeln("\"日\" );");
document.writeln("");
document.writeln("return 0; ");
document.writeln("}");
document.writeln("function GetLeap( year )");
document.writeln("{");
document.writeln("if ( year % 400 == 0 )");
document.writeln("return 1;");
document.writeln("else if ( year % 100 == 0 )");
document.writeln("return 0;");
document.writeln("else if ( year % 4 == 0 )");
document.writeln("return 1;");
document.writeln("else");
document.writeln("return 0;");
document.writeln("}");
document.writeln("function tagLunarCal( d, i, w, k, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13) {");
document.writeln("this.BaseDays = d; \/* 到民國 1 月 1 日到農曆正月初一的累積日數 *\/");
document.writeln("this.Intercalation = i; \/* 閏月月份. 0==此年沒有閏月 *\/");
document.writeln("this.BaseWeekday = w; \/* 此年民國 1 月 1 日為星期幾再減 1 *\/");
document.writeln("this.BaseKanChih = k; \/* 此年民國 1 月 1 日之干支序號減 1 *\/");
document.writeln("this.MonthDays = [ m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13 ]; \/* 此農曆年每月之大 ");
document.writeln("小, 0==小月(29日), 1==大月(30日) *\/");
document.writeln("}");
document.writeln("CalConv();");
document.writeln("<\/script> ")