/*** 음력 ***/ var sc_LUNAR = function(y, m){ this.ssolar2lunar; //음력 구한 데이터보관 this.lunar_data = { "year":"", "month":"", "day":"", "yoon":false }; this.month_last = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; this.LunarTable = [ // 1881-2050년까지의 음력 데이터 //1881 "1212122322121", "1212121221220", "1121121222120", "2112132122122", "2112112121220", "2121211212120", "2212321121212", "2122121121210", "2122121212120", "1232122121212", //1891 "1212121221220", "1121123221222", "1121121212220", "1212112121220", "2121231212121", "2221211212120", "1221212121210", "2123221212121", "2121212212120", "1211212232212", //1901 "1211212122210", "2121121212220", "1212132112212", "2212112112210", "2212211212120", "1221412121212", "1212122121210", "2112212122120", "1231212122212", "1211212122210", //1911 "2121123122122", "2121121122120", "2212112112120", "2212231212112", "2122121212120", "1212122121210", "2132122122121", "2112121222120", "1211212322122", "1211211221220", //1921 "2121121121220", "2122132112122", "1221212121120", "2121221212110", "2122321221212", "1121212212210", "2112121221220", "1231211221222", "1211211212220", "1221123121221", //1931 "2221121121210", "2221212112120", "1221241212112", "1212212212120", "1121212212210", "2114121212221", "2112112122210", "2211211412212", "2211211212120", "2212121121210", //1941 "2212214112121", "2122122121120", "1212122122120", "1121412122122", "1121121222120", "2112112122120", "2231211212122", "2121211212120", "2212121321212", "2122121121210", //1951 "2122121212120", "1212142121212", "1211221221220", "1121121221220", "2114112121222", "1212112121220", "2121211232122", "1221211212120", "1221212121210", "2121223212121", //1961 "2121212212120", "1211212212210", "2121321212221", "2121121212220", "1212112112210", "2223211211221", "2212211212120", "1221212321212", "1212122121210", "2112212122120", //1971 "1211232122212", "1211212122210", "2121121122210", "2212312112212", "2212112112120", "2212121232112", "2122121212110", "2212122121210", "2112124122121", "2112121221220", //1981 "1211211221220", "2121321122122", "2121121121220", "2122112112322", "1221212112120", "1221221212110", "2122123221212", "1121212212210", "2112121221220", "1211231212222", //1991 "1211211212220", "1221121121220", "1223212112121", "2221212112120", "1221221232112", "1212212122120", "1121212212210", "2112132212221", "2112112122210", "2211211212210", //2001 "2221321121212", "2212121121210", "2212212112120", "1232212122112", "1212122122110", "2121212322122", "1121121222120", "2112112122120", "2211231212122", "2121211212120", //2011 "2122121121210", "2124212112121", "2122121212120", "1212121223212", "1211212221210", "2121121221220", "2112132121222", "1212112121220", "2121211212120", "2122321121212", //2021 "1221212121210", "2121221212120", "1232121221212", "1211212212210", "2121123212221", "2121121212220", "1212112112220", "1221231211221", "2212211211220", "1212212121210", //2031 "2123212212121", "2112122122120", "1211212322212", "1211212122210", "2121121122120", "2212114112122", "2212112112120", "2212121211210", "2212232121211", "2122122121210", //2041 "2112122122120", "1231212122212", "1211211221220", "2121121321222", "2121121121220", "2122112112120", "2122141211212", "1221221212110", "2121221221210", "2114121221221" ]; this.solar2lunar = function(year, month, day){ if(year<1881 || year>2050){ this.lunar_data.year = ""; this.lunar_data.month = ""; this.lunar_data.day = ""; this.lunar_data.yoon = false; return this.lunar_data; } var first_day = 686685; if( (year%400==0) || ((year%4==0)&&(year%100!=0)) ){ this.month_last[1]=29; } else { this.month_last[1]=28; } var sum = 0; for(var i=0; i 2) { break; } yun++; } while(yun <= 12); return yun - 1; }; this.make_lunar = function(year, month){ this.ssolar2lunar = new Array(); if(year<1881 || year>2050) { this.lunar_data.year=""; this.lunar_data.month=""; this.lunar_data.day=""; this.lunar_data.yoon=false; for(var i=0; i<31; i++) this.ssolar2lunar[i] = this.lunar_data; return false; } if( (year%400==0)|| ((year%4==0)&&(year%100!=0)) ){ this.month_last[1]=29; } else { this.month_last[1]=28; } var solar_day = 1; this.lunar_data = this.solar2lunar(year, month, solar_day); this.lunar_data.month--; // 계산을 위하여 월을 0부터로 변경 var one_lunar = {"year":"", "month":"", "day":"", "last":"", "yoon":false}; do{ one_lunar.year = this.lunar_data.year; one_lunar.month = this.lunar_data.month + 1; // 결과는 1월 부터이다. one_lunar.day = this.lunar_data.day; one_lunar.yoon = this.lunar_data.yoon; one_lunar.last = this.nDaysMonth(); this.ssolar2lunar[solar_day-1] = {"year":one_lunar.year, "month":one_lunar.month, "day":one_lunar.day, "last":one_lunar.last, "yoon":one_lunar.yoon}; if(this.lunar_data.day >= this.nDaysMonth()) { if(this.lunar_data.month < 11) { if((this.lunar_data.month == this.YunMonth()) && !this.lunar_data.yoon){ this.lunar_data.yoon = true; this.lunar_data.day = 1; } else { this.lunar_data.month++; this.lunar_data.yoon = false; this.lunar_data.day = 1; } } else { this.lunar_data.year++; this.lunar_data.month = 0; this.lunar_data.day = 1; } } else { this.lunar_data.day++; } }while(++solar_day <= this.month_last[month-1]); }; this.get_lunar = function(day){ day--; return this.solar2lunar[day]; } this.toString = function(){ if(this.ssolar2lunar.length>0){ var s = ''; for(var i=0; i { year: ' + this.ssolar2lunar[i].year + ', month: ' + this.ssolar2lunar[i].month + ', day: ' + this.ssolar2lunar[i].day + ', yoon: ' + this.ssolar2lunar[i].yoon + '}\n'; } return s; }else{ return ""; } } this.make_lunar(y, m); };