양력을 음력으로 변환하는 PHP 클래스

WBOY
풀어 주다: 2016-07-25 08:42:23
원래의
894명이 탐색했습니다.
  1. //PHP 양력을 음력으로 변환하는 클래스
  2. class Calendar
  3. {
  4. #각 일수 음력의 달
  5. var $everyCMonth=array(
  6. 0=>array(8,0,0,0,0,0,0,0,0,0,0,0,29,30 ,7,1),
  7. 1=>배열(0,29,30,29,29,30,29,30,29,30,30,30,29,0,8,2),
  8. 2=>배열(0 ,30,29,30,29,29,30,29,30,29,30,30,30,0,9,3),
  9. 3=>배열(5 ,29,30,29,30 ,29,29,30,29,29,30,30,29,30,10,4),
  10. 4=>배열(0,30,30,29,30 ,29,29,30,29 ,29,30,30,29,0,1,5),
  11. 5=>배열(0,30,30,29,30,30,29,29,30 ,29,30,29,30,0,2,6),
  12. 6=>배열(4,29,30,30,29,30,29,30,29,30,29,30,29 ,30,3,7),
  13. 7=>배열(0,29,30,29,30,29,30,30,29,30,29,30,29,0,4,8),
  14. 8=>배열(0,30,29,29,30,30,29,30,29,30,30,29,30,0,5,9),
  15. 9=>배열 (2,29,30,29,29,30,29,30,29,30,30,30,29,30,6,10),
  16. 10=>배열(0,29,30,29 ,29,30,29,30 ,29,30,30,30,29,0,7,11),
  17. 11=>배열(6,30,29,30,29,29,30,29 ,29,30,30,29,30,30,8,12),
  18. 12=>배열(0,30,29,30,29,29,30,29,29,30,30,29 ,30,0,9,1 ),
  19. 13=>배열(0,30,30,29,30,29,29,30,29,29,30,29,30,0,10,2 ),
  20. 14=> ;배열(5,30,30,29,30,29,30,29,30,29,30,29,29,30,1,3),
  21. 15=> ;배열(0,30,29,30,30,29,30,29,30,29,30,29,30,0,2,4),
  22. 16=>배열(0,29,30 ,29,30,29,30 ,30,29,30,29,30,29,0,3,5),
  23. 17=>배열(2,30,29,29,30,29,30 ,30,29,30,30,29,30,29,4,6),
  24. 18=>배열(0,30,29,29,30,29,30,29,30,30,29 ,30,30,0,5,7),
  25. 19=>배열(7,29,30,29,29,30,29,29,30,30,29,30,30,30,6 ,8),
  26. 20 =>배열(0,29,30,29,29,30,29,29,30,30,29,30,30,0,7,9),
  27. 21 =>배열(0,30,29,30,29,29,30,29,29,30,29,30,30,0,8,10),
  28. 22=>배열(5,30 ,29,30,30,29 ,29,30,29,29,30,29,30,30,9,11),
  29. 23=>배열(0,29,30,30,29,30 ,29,30,29,29 ,30,29,30,0,10,12),
  30. 24=>배열(0,29,30,30,29,30,30,29,30,29 ,30,29,29,0,1,1),
  31. 25=>배열(4,30,29,30,29,30,30,29,30,30,29,30,29,30 ,2,2),
  32. 26=>배열(0,29,29,30,29,30,29,30,30,29,30,30,29,0,3,3),
  33. 27=>배열(0 ,30,29,29,30,29,30,29,30,29,30,30,30,0,4,4),
  34. 28=>배열(2 ,29,30,29,29 ,30,29,29,30,29,30,30,30,30,5,5),
  35. 29=>배열(0,29,30,29,29 ,30,29,29,30 ,29,30,30,30,0,6,6),
  36. 30=>배열(6,29,30,30,29,29,30,29,29 ,30,29,30,30,29,7,7),
  37. 31=>배열(0,30,30,29,30,29,30,29,29,30,29,30,29 ,0,8,8),
  38. 32=>배열(0,30,30,30,29,30,29,30,29,29,30,29,30,0,9,9),
  39. 33=>배열(5,29,30,30,29,30,30,29,30,29,30,29,29,30,10,10),
  40. 34=>배열 (0,29,30,29,30,30,29,30,29,30,30,29,30,0,1,11),
  41. 35=>배열(0,29,29,30 ,29,30,29,30 ,30,29,30,30,29,0,2,12),
  42. 36=>배열(3,30,29,29,30,29,29,30 ,30,29,30,30,30,29,3,1),
  43. 37=>배열(0,30,29,29,30,29,29,30,29,30,30,30 ,29,0,4,2 ),
  44. 38=>배열(7,30,30,29,29,30,29,29,30,29,30,30,29,30,5,3 ),
  45. 39=> ;배열(0,30,30,29,29,30,29,29,30,29,30,29,30,0,6,4),
  46. 40=> ;배열(0,30,30,29,30,29,30,29,29,30,29,30,29,0,7,5),
  47. 41=>배열(6,30,30 ,29,30,30,29 ,30,29,29,30,29,30,29,8,6),
  48. 42=>배열(0,30,29,30,30,29,30 ,29,30,29,30 ,29,30,0,9,7),
  49. 43=>배열(0,29,30,29,30,29,30,30,29,30,29 ,30,29,0,10,8),
  50. 44=>배열(4,30,29,30,29,30,29,30,29,30,30,29,30,30,1 ,9),
  51. 45 =>배열(0,29,29,30,29,29,30,29,30,30,30,29,30,0,2,10),
  52. 46 =>배열(0,30,29,29,30,29,29,30,29,30,30,29,30,0,3,11),
  53. 47=>배열(2,30 ,30,29,29,30 ,29,29,30,29,30,29,30,30,4,12),
  54. 48=>배열(0,30,29,30,29,30 ,29,29,30,29 ,30,29,30,0,5,1),
  55. 49=>배열(7,30,29,30,30,29,30,29,29,30 ,29,30,29,30,6,2),
  56. 50=>배열(0,29,30,30,29,30,30,29,29,30,29,30,29,0 ,7,3),
  57. 51=>배열(0,30,29,30,30,29,30,29,30,29,30,29,30,0,8,4),
  58. 52=>배열(5 ,29,30,29,30,29,30,29,30,30,29,30,29,30,9,5),
  59. 53=>배열(0 ,29,30,29,29 ,30,30,29,30,30,29,30,29,0,10,6),
  60. 54=>배열(0,30,29,30,29 ,29,30,29,30 ,30,29,30,30,0,1,7),
  61. 55=>배열(3,29,30,29,30,29,29,30,29 ,30,29,30,30,30,2,8),
  62. 56=>배열(0,29,30,29,30,29,29,30,29,30,29,30,30 ,0,3,9),
  63. 57=>배열(8,30,29,30,29,30,29,29,30,29,30,29,30,29,4,10),
  64. 58=>배열(0,30,30,30,29,30,29,29,30,29,30,29,30,0,5,11),
  65. 59=>배열 (0,29,30,30,29,30,29,30,29,30,29,30,29,0,6,12),
  66. 60=>배열(6,30,29,30 ,29,30,30,29 ,30,29,30,29,30,29,7,1),
  67. 61=>배열(0,30,29,30,29,30,29,30 ,30,29,30,29,30,0,8,2),
  68. 62=>배열(0,29,30,29,29,30,29,30,30,29,30,30 ,29,0,9,3 ),
  69. 63=>배열(4,30,29,30,29,29,30,29,30,29,30,30,30,29,10,4 ),
  70. 64=> ;배열(0,30,29,30,29,29,30,29,30,29,30,30,30,0,1,5),
  71. 65=> ;배열(0,29,30,29,30,29,29,30,29,29,30,30,29,0,2,6),
  72. 66=>배열(3,30,30 ,30,29,30,29 ,29,30,29,29,30,30,29,3,7),
  73. 67=>배열(0,30,30,29,30,30,29,29,30,29,30,29,30,0,4,8),
  74. 68=>배열(7, 29,30,29,30,30,29,30,29,30,29,30,29,30,5,9),
  75. 69=>배열(0,29,30,29,30, 29,30,30,29,30,29,30,29,0,6,10),
  76. 70=>배열(0,30,29,29,30,29,30,30,29, 30,30,29,30,0,7,11),
  77. 71=>배열(5,29,30,29,29,30,29,30,29,30,30,30,29, 30,8,12),
  78. 72=>배열(0,29,30,29,29,30,29,30,29,30,30,29,30,0,9,1),
  79. 73=>배열(0,30,29,30,29,29,30,29,29,30,30,29,30,0,10,2),
  80. 74=>배열( 4,30,30,29,30,29,29,30,29,29,30,30,29,30,1,3),
  81. 75=>배열(0,30,30,29, 30,29,29,30,29,29,30,29,30,0,2,4),
  82. 76=>배열(8,30,30,29,30,29,30,29, 30,29,29,30,29,30,3,5),
  83. 77=>배열(0,30,29,30,30,29,30,29,30,29,30,29, 29,0,4,6),
  84. 78=>배열(0,30,29,30,30,29,30,30,29,30,29,30,29,0,5,7) ,
  85. 79=>배열(6,30,29,29,30,29,30,30,29,30,30,29,30,29,6,8),
  86. 80=> 배열(0,30,29,29,30,29,30,29,30,30,29,30,30,0,7,9),
  87. 81=>배열(0,29,30, 29,29,30,29,29,30,30,29,30,30,0,8,10),
  88. 82=>배열(4,30,29,30,29,29,30, 29,29,30,29,30,30,30,9,11),
  89. 83=>배열(0,30,29,30,29,29,30,29,29,30,29, 30,30,0,10,12),
  90. 84=>배열(10,30,29,30,30,29,29,30,29,29,30,29,30,30,1, 1),
  91. 85=>배열(0,29,30,30,29,30,29,30,29,29,30,29,30,0,2,2),
  92. 86= >배열(0,29,30,30,29,30,30,29,30,29,30,29,29,0,3,3),
  93. 87=>배열(6,30, 29,30,29,30,30,29,30,30,29,30,29,29,4,4),
  94. 88=>배열(0,30,29,30,29,30, 29,30,30,29,30,30,29,0,5,5),
  95. 89=>배열(0,30,29,29,30,29,29,30,30,29, 30,30,30,0,6,6),
  96. 90=>배열(5,29,30,29,29,30,29,29,30,29,30,30,30,30, 7,7),
  97. 91=>배열(0,29,30,29,29,30,29,29,30,29,30,30,30,0,8,8),
  98. 92=>배열(0,29,30,30,29,29,30,29,29,30,29,30,30,0,9,9),
  99. 93=>배열(3, 29,30,30,29,30,29,30,29,29,30,29,30,29,10,10),
  100. 94=>배열(0,30,30,30,29, 30,29,30,29,29,30,29,30,0,1,11),
  101. 95=>배열(8,29,30,30,29,30,29,30,30, 29,29,30,29,30,2,12),
  102. 96=>배열(0,29,30,29,30,30,29,30,29,30,30,29,29, 0,3,1),
  103. 97=>배열(0,30,29,30,29,30,29,30,30,29,30,30,29,0,4,2),
  104. 98=>배열(5,30,29,29,30,29,29,30,30,29,30,30,29,30,5,3),
  105. 99=>배열( 0,30,29,29,30,29,29,30,29,30,30,30,29,0,6,4),
  106. 100=>배열(0,30,30,29, 29,30,29,29,30,29,30,30,29,0,7,5),
  107. 101=>배열(4,30,30,29,30,29,30,29, 29,30,29,30,29,30,8,6),
  108. 102=>배열(0,30,30,29,30,29,30,29,29,30,29,30, 29,0,9,7),
  109. 103=>배열(0,30,30,29,30,30,29,30,29,29,30,29,30,0,10,8) ,
  110. 104=>배열(2,29,30,29,30,30,29,30,29,30,29,30,29,30,1,9),
  111. 105=> 배열(0,29,30,29,30,29,30,30,29,30,29,30,29,0,2,10),
  112. 106=>배열(7,30,29, 30,29,30,29,30,29,30,30,29,30,30,3,11),
  113. 107=>배열(0,29,29,30,29,29,30, 29,30,30,30,29,30,0,4,12),
  114. 108=>배열(0,30,29,29,30,29,29,30,29,30,30, 29,30,0,5,1),
  115. 109=>배열(5,30,30,29,29,30,29,29,30,29,30,29,30,30,6, 2),
  116. 110=>배열(0,30,29,30,29,30,29,29,30,29,30,29,30,0,7,3),
  117. 111= >배열(0,30,29,30,30,29,30,29,29,30,29,30,29,0,8,4),
  118. 112=>배열(4,30, 29,30,30,29,30,29,30,29,30,29,30,29,9,5),
  119. 113=>배열(0,30,29,30,29,30, 30,29,30,29,30,29,30,0,10,6),
  120. 114=>배열(9,29,30,29,30,29,30,29,30,30, 29,30,29,30,1,7),
  121. 115=>배열(0,29,30,29,29,30,29,30,30,30,29,30,29,0, 2,8),
  122. 116=>배열(0,30,29,30,29,29,30,29,30,30,29,30,30,0,3,9),
  123. 117=>배열(6,29,30,29,30,29,29,30,29,30,29,30,30,30,4,10),
  124. 118=>배열(0, 29,30,29,30,29,29,30,29,30,29,30,30,0,5,11),
  125. 119=>배열(0,30,29,30,29, 30,29,29,30,29,29,30,30,0,6,12),
  126. 120=>배열(4,29,30,30,30,29,30,29,29, 30,29,30,29,30,7,1)
  127. );
  128. ######################### ##
  129. #农历天干
  130. var $mten=array("null","甲","乙","丙","丁","戊","己","庚","辛","壬","癸"); #农历地支
  131. var $mtwelve=array("null","子(鼠)","丑(牛)","寅(虎)","卯(兔)","辰(龙)" ,
  132. "巳(蛇)","午(马)","未(羊)","申(猴)","酉(鸡)","戌(狗)","亥(猪)"); #农历月份
  133. var $mmonth=array("금","정","이","삼","사","五","六",
  134. "금","八" ,"九","十","十一","十이","월");
  135. var $mday=array("null","初一","初이","初三","初4","初五","初六","初七","初八","初九","初十",
  136. "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
  137. "21", " 스물둘", "스물셋", "스물넷", "스물다섯", "스물여섯", "스물일곱", "스물여덟", "스물아홉", "셋" 10");#설날
  138. #########################
  139. #초기값 지정
  140. #天干地肖
  141. var $ten=0;
  142. var $twelve=0;
  143. function MyPub($cYear,$cMonth,$cDay)
  144. {
  145. $total=11;# 합계 1900년 12월 21일까지의 양력 일수
  146. $mtotal=0;#음력의 총 일수
  147. for ($y=1901;$y<$cYear;$y)
  148. {
  149. $total =365;
  150. if ($y%4==0) $total ;
  151. }
  152. #연중 월 추가
  153. 스위치($cMonth){
  154. 사례 12:
  155. $total =30;
  156. 사례 11:
  157. $total =31;
  158. 사례 10:
  159. $total =30;
  160. 사례 9:
  161. $total =31;
  162. 사례 8:
  163. $total =31;
  164. 사례 7:
  165. $total =30;
  166. 사례 6:
  167. $total =31;
  168. 사례 5:
  169. $total =30;
  170. 사례 4:
  171. $total =31;
  172. 사례 3:
  173. $total =28;
  174. 사례 2:
  175. $ total =31;
  176. }
  177. #올해가 윤년이면 하루를 더합니다
  178. if ($cYear%4==0 and $cMonth>2)
  179. {
  180. $total ;
  181. }
  182. $total =$cDay-1;
  183. ################### ########
  184. #음력의 누적 일수를 사용하여 양력의 일수를 초과하는지 확인
  185. for($j=0;$j<=120 ;$j )
  186. {
  187. $i=1;
  188. for( $i=1;$i<=13;$i )
  189. {
  190. $mtotal =$this-> EveryCMonth[$j][$i];
  191. if ($mtotal>=$total )
  192. {
  193. $flag=1;
  194. break;
  195. }
  196. }
  197. if ($flag==1)break;
  198. }
  199. return array(" m"=>$j,"d"=>$i,"t"=>$total,"n" =>$mtotal);
  200. }
  201. 함수 Cal($Year,$ Month,$Day)
  202. {
  203. $Par=$this->MyPub($Year,$Month,$ 일);
  204. $md=$this->everyCMonth[$Par ["m"]][$Par["d"]]-($Par["n"]-$Par[" t"]);
  205. $week=($Par["t"] 5) %7;
  206. if ($this->everyCMonth[$Par["m"]][0]<> ;0 및 $this->everyCMonth[$Par["m"]][0] <$Par["d"])
  207. {
  208. $mm=$Par["d"]-1 ;
  209. }else{
  210. $mm=$Par["d"];
  211. }
  212. if ($Par["d"]==$this->everyCMonth[$Par[" d"]][0] 1 및 $this->everyCMonth[$Par["d "]][0]<>0)
  213. {
  214. $cMonth=$this->mmonth[ 0].$this->mmonth[$mm];#윤달
  215. }else {
  216. $cMonth=$this->mmonth[$mm].$this->mmonth[13];
  217. }
  218. return array("year"=>$this->mten [$this->everyCMonth[$Par["m"]][14]].$this->mtwelve[ $this->everyCMonth[$Par["m"]][15]],
  219. "월"=>$cMonth,
  220. "일"=>$this->mday[$md ],
  221. "week"=>$week);
  222. }
  223. }
  224. /////Call
  225. $test=new Calendar;
  226. $Year=$test- >Cal(2004,2,20);
  227. echo $Year["year"] ."year".$Year["month"].$Year["day"]."week".$Year[ "주"];
  228. ?>
코드 복사

PHP


원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿