Attention time, pay attention, formname is like Document.Search, M = 0 is a lunar calendar, m = 1 is a lunar calendar, and pay attention to the day, the client is written:
Lunar Date: Year Month Japan
Enter the Comel Date: Year Month Japan
This will ensure that it can be used normally, and the function is calculated what year is
Waiting for time to turn into Java version
// Lunar Date VAR NDATE; // CHENG Date VAR YDATE; / / Calculate what year is the year, pay attention to the VAR Animal calculated according to the lunar calendar;
Function getndate () {return ndate;} function getanimal () {Return Animal;} Function Calconv (Formname, M) {firstyear = 1936; la castyear = 2031;
Lunarcal =
[New Taglunarcal (23, 3, 2, 17, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0), / * 1936 * / New Taglunarcal (41, 0 , 4, 23, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1), New Taglunarcal (30, 7, 5, 28, 1, 1, 0, 0 , 1, 0, 0, 1), New Taglunarcal (49, 0, 6, 33, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1) , 0, 1, 1), New Taglunarcal (38, 0, 0, 38, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1), / * 1940 * / New Taglunarcal (26, 6, 2, 44, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0), new taglunarcal (45, 0, 3, 49, 1, 0, 1, 1, 0, 1, 0), 1, 0), New Taglunarcal (35, 0, 4, 54, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1), New Taglunarcal (24, 4, 5, 59, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1), / * 1944 * / New Taglunarcal (43, 0, 0, 5, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1), new taglunarcal (32 , 0, 1, 10, 1, 0, 0, 1, 1, 0, 1, 1), New Taglunarcal (21, 2, 2, 15, 1, 1, 0 , 0, 1, 0, 0, 1, 0, 1, 0, 1), New Taglunarcal (40, 0, 3, 20, 1, 0, 1, 0, 1, 0, 0, 1, 0) , 1, 0, 1, 1), / * 194 8 * / New Taglunarcal (28, 7, 5, 26, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1), new taglunarcal (47, 0, 6, 31, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1), new taglunarcal (36, 0, 0, 36, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0), New Taglunarcal (26, 5, 1, 41, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1), / * 1952 * / New Taglunarcal (44, 0, 3, 47, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1), new taglunarcal (33, 0, 4, 52, 1, 0, 1, 0, 0, 1, 0), new taglunarcal (23, 3, 5, 57, 0, 1) , 0, 1, 0, 1, 1), new Taglunarcal (42, 0, 6, 2, 0, 1, 0, 1, 0, 0, 1, 0 , 1, 0, 1, 1), / * 1956 * / New Taglunarcal (30, 8, 1, 8, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0), New Taglunarcal (48, 0, 2, 13, 1, 1, 1, 0, 1, 0, 0, 1, 0,
1, 0, 1, 0), New Taglunarcal (38, 0, 3, 18, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1), new taglunarcal ( 27, 6, 4, 23, 1, 0, 1, 0, 1, 0, 1, 0), / * 1960 * / New Taglunarcal (45, 0, 6, 29 , 1, 0, 1, 0, 1, 0, 1, 0), New Taglunarcal (35, 0, 0, 34, 0, 1, 0, 0, 1, 0 , 1, 1, 1), New Taglunarcal (24, 4, 1, 39, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1) , 0), New Taglunarcal (43, 0, 2, 44, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0), / * 1964 * / New Taglunarcal 32, 0, 4, 50, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1), new taglunarcal (20, 3, 5, 55, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0), New Taglunarcal (39, 0, 6, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0), New Taglunarcal (29, 7, 0, 5, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1), / * 1968 * / New Taglunarcal (47, 0, 2, 11, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1), new taglunarcal (36, 0, 3 , 16, 1, 0, 1, 1, 0, 1, 0), New Taglunarcal (26, 5, 4, 21, 0, 1, 0, 0, 1) , 0, 1, 0, 1, 1, 1, 0 , 1), New Taglunarcal (45, 0, 5, 26, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1), / * 1972 * / New Taglunarcal 33, 0, 0, 32, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1), new Taglunarcal (22, 4, 1, 37, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1), New Taglunarcal (41, 0, 2, 42, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1), New Taglunarcal (30, 8, 3, 47, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1), / * 1976 * / New Taglunarcal (48, 0, 5, 53, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1), new taglunarcal (37, 0, 6 , 58, 1, 0, 1, 0, 1, 0, 1), New Taglunarcal (27, 6, 0, 3, 1, 0, 0, 1, 0) , 1, 1, 0), New Taglunarcal (46, 0, 1, 8, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1) , 1, 0), / * 1980 * / New Taglunarcal (35, 0, 3, 14, 0, 1, 0, 0,
1, 0, 0, 1, 1, 0, 1, 1, 1), New Taglunarcal (24, 4, 4, 19, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1), New Taglunarcal (43, 0, 5, 24, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1), new taglunarcal (32, 10, 6, 29, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1), / * 1984 * / New Taglunarcal (50, 0, 1, 35, 0 , 1, 1, 0, 1, 0, 1, 0), New Taglunarcal (39, 0, 2, 40, 0, 1, 1, 0, 1, 1, 0) , 1, 0, 1, 0, 0, 1), New Taglunarcal (28, 6, 3, 45, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0) ), New Taglunarcal (47, 0, 4, 50, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1), / * 1988 * / new taglunarcal (36, 0, 6, 56, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0), NEW TAGLunarcal (26, 5, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1), New Taglunarcal (45, 0, 1, 6, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0), New Taglunarcal (34, 0, 2, 11, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0), / * 1992 * / New Taglunarcal (22, 3, 4, 17, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0), new Taglunarcal (40, 0, 5, 22 , 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0), New Taglunarcal (30, 8, 6, 27, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1), New Taglunarcal (49, 0, 0, 32, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1), / * 1996 * / new Taglunarcal (37 , 0, 2, 38, 1, 0, 1, 0, 1, 0, 1), NEW TAGLunarcal (27, 5, 3, 43, 1, 0, 0 , 1, 0, 0, 1), New Taglunarcal (46, 0, 4, 48, 1, 0, 0, 1, 0, 0, 1, 0, 1) , 1, 1, 0, 1), / * 1999 * / New Taglunarcal (35, 0, 5, 53, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0) 1), / * 2000 * / New Taglunarcal (23, 4, 0, 59, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1), new taglunarcal (42 , 0, 1, 4, 1, 1, 0, 1, 0, 1, 1), New Taglunarcal (31, 0, 2, 9, 1, 1, 0 , 1, 1, 0, 1, 0, 0, 1, 0, 1, 0), New Taglunarcal (21, 2,
3, 14, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1), / * 2004 * / New Taglunarcal (39, 0, 5, 20, 0, 1 , 0, 1, 0, 1, 1, 0, 1), New Taglunarcal (28, 7, 6, 25, 1, 0, 1, 0, 1, 0, 1, 0) , 1, 1, 0, 1, 1), New Taglunarcal (48, 0, 0, 30, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1), New Taglunarcal (37, 0, 1, 35, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1), / * 2008 * / new Taglunarcal (25, 5, 3, 41, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1), New Taglunarcal (44, 0, 4, 46, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1), New Taglunarcal (33, 0, 5, 51, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1), New Taglunarcal (22, 4, 6, 56, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0), / * 2012 * / New Taglunarcal (40, 0, 1, 2, 1, 0, 1, 1, 0, 1, 0), 0, 1, 0, 0), NEW TAGLunarcal (30, 9, 2, 7, 0 , 1, 0, 1, 0, 1, 0, 1), new taglunarcal (49, 0, 3, 12, 0, 1, 0, 0, 1, 0, 1) , 1, 1, 0, 1, 0, 1), NEW TAGLunarcal (38, 0, 4, 17, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0) ), / * 2016 * / new taglunarcal (27 , 6, 6, 23, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1), New Taglunarcal (46, 0, 0, 28, 0, 1, 0 , 1, 0, 0, 1, 0, 1, 0, 1, 0), New Taglunarcal (35, 0, 1, 33, 0, 1, 1, 0, 1, 0, 0, 1, 0) , 0, 1, 1, 0), New Taglunarcal (24, 4, 2, 38, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1), / * 2020 * / New Taglunarcal (42, 0, 4, 44, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1), new taglunarcal (31, 0, 5, 49, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0), New Taglunarcal (21, 2, 6, 54, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1), New Taglunarcal (40, 0, 0, 59, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1), / * 2024 * / New Taglunarcal (28, 6, 2, 5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0), new taglunarcal (47, 0, 3, 10, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1),
New Taglunarcal (36, 0, 4, 15, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1), new taglunarcal (25, 5, 5, 20, 1 , 1, 1, 0, 1, 0, 0, 1, 0, 0), / * 2028 * / New Taglunarcal (43, 0, 0, 26, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1), New Taglunarcal (32, 0, 1, 31, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0), New Taglunarcal (22, 3, 2, 36, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0)]; / * The number of days per month * / solarcal = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
/ * The number of days per month, the number of days and leap years * / solardays = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396, 0, 31 , 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 397];
Animalidx = ["Niu", "Rat", "Pig", "Dog", "Chicken", "Monkey", "Sheep", "Horse", "Snake", "Dragon", "Rabbit", "Tiger" ]; // locationidx = [South "," East "," North "," West "]; if (m == 0) {// Cumulatory calendar to the lunar calendar IF (! Isinteger (formname.year.value) || Isinteger (formname.ymonth.value) ||! ISINTEGER ("Please enter the valuable value of the legality"); Solaryear = PARSEINT (FormName.Year.Value); SolarMonth = PARSEINT (formname.ymonth.value); solardate = parseint (formname.yday.value);
IF (Solaryear <= firstyear || Solaryear> Lastyear) Return Alert ("Please enter 1936-2031 effective year");
SM = Solarmonth - 1; IF (SM <0 || SM> 11) Return Alert (please enter the valid month); Leap = getleap (Solaryear);
IF (SM == 1) D = Leap 28; ELSE D = Solarcal [SM];
IF (Solardate <1 || Solardate> D) Return 3;
y = Solaryear - Firstyear; ACC = SolarDays [Leap * 14 SM] Solardate; KC = ACC Lunarcal [Y] .BasekAnchiH; Kan = KC% 10; // location = locationIDX [KC% 4]; age = kc % 60; IF (Age <22) age = 22 - age; else agn = 82 - age; agent = age 3;
IF (age <10) agn = age 60;
Animal = animalidx [anim];
IF (ACC <= Lunarcal [Y] .BaseDays) {y -; lunaryear = Solaryear - 1; Leap = getleap (Lunaryear); SM = 12; ACC = SolarDays [Leap * 14 SM] Solardate;} else Lunaryear = Solaryear; L1 = Lunarcal [Y] .BaseDays; for (i = 0; i <13; i ) {l2 = l1 lunarcal [y] .MONTHDAYS [I] 29; IF (ACC <= L2) BREAK ; L1 = L2;}
Lunarmonth = i 1; Lunardate = ACC - L1; IM = Lunarcal [Y] .intercalation;
IF (im! = 0 && lunarmonth> IM) {lunarmonth-; if (lunarmonth == im) lunarmonth = -im;}
IF (lunarmonth> 12) lunarmonth - = 12;
// Alert ("Lunar calendar:" Lunaryear "Year" Lunarmonth "Month" Lunardate "Day"); NDATE = LunaryEar "-" Lunarmonth " Lunardate;
// Calculate the zodiac Anim = 12-math.abs ((LunaryEar-1901)% 12); Animal = Animalidx [Anim]; Return 0;}
Else / * Lunar Calendar * / {if (! isinteger (formname.Nyear.Value) ||! isinteger (formname.nmonth.value) ||! isinteger (Formname.nday.Value) Return Alert ("Please enter legal Lunar Monthly Month (Formname.Nyear.Value); Lunarmonth = PARSEINT (FormName.nMonth.Value); Lunardate = PARSEINT (Formname.nday.Value);
IF (lunaryear
ACC = 0; for (i = 0; i ACC = Lunarcal [Y] .Monthdays [i] 29;} ACC = Lunarcal [Y] .Basedays Lunardate; Leap = GetleAP (Lunaryear); for (i = 13; i> = 0; I -) { IF (ACC> SolarDays [Leap * 14 I]) Break;} solardate = ACC - SolarDays [leap * 14 i]; if (i <= 11) {solaryear = lunaryear; SolarMonth = i 1;} else { Solaryear = LunaryEar 1; Solarmonth = I - 11;} leap = getleap (Solaryear); Y = Solaryear - firstyear; // ACC = SolarDays [leap] [SolarMonth-1] SolarDate; ACC = SolarDays [Leap * 14 Solarmonth-1] solardate; weekday = (ACC L UNARCAL [Y] .Baseweekday% 7; KC = ACC Lunarcal [Y] .Basekanchih; kan = kc% 10; chih = kc% 12; // alert ("The yang is:" Solaryear "year" Solarmonth "Month" Solardate "Day"); YDATE = Solaryear "-" SolarMonth "-" Solardate; Return 0;} // ELSE End} / * Leap year, returned to 0% year, 1 leap year * / function getleap (Year) {if (Year% 400 == 0) Return 1; Else IF (Year% 100 == 0) Return 0; Else IF (Year% 4 = = 0) RETURN 1; Else Return 0;} Function Taglunarcal (D, I, W, K, M1, M2, M3, M4, M5, M6, M7, M8, M9, M10, M11, M12, M13) {THIS .BaseDays = D; / * January 1 to the first day of the first month of the first month * / this.intercalation = i; / * 月 月 月. 0 == This year does not have a month * / this.baseweekday = W; / * This year January 1 * / this.basekanchih = k; / * January 1 this year, the serial number minus 1 * / this.monthdays = [M1, M2, M3, M4, M5, M6, M7, M8, M9, M10, M11, M12, M13]; / * This lunar year size, 0 == Xiaoyue (29th), 1 == Dali (30th) * /} Function isinteger (String, Sign) {var integer; if ((Sign! = NULL) && (Sign! = '-') && (Sign! = ' ')) {Alert ('Isinter (String, Sign) parameters Error: nsign is NULL or "-" or " "); return false;} integer = parseint (String); if (ISNAN) {Return False;} else if (Integer.toString (). Length = = String.Length) {IF ((Sign == NULL) || (Sign == '-' && Integer <0) || (SIGN == ' ' && Integer> 0)) {Return True;} else return else;} else returse;