ホームページ > バックエンド開発 > PHPチュートリアル > 太陽暦を太陰暦に変換するための PHP クラス

太陽暦を太陰暦に変換するための PHP クラス

WBOY
リリース: 2016-07-25 08:56:06
オリジナル
943 人が閲覧しました
  1. /**
  2. * クラス: 太陽暦を太陰暦に変換するクラス
  3. * エディタ: bbs.it-home.org
  4. * /
  5. class Calendar{
  6. var $everyCMonth=array(
  7. 0= >配列(8,0,0,0,0,0,0,0,0,0,0,0,29,30,7,1)、
  8. 1=>配列(0,29 ,30, 29,29,30,29,30,29,30,30,30,29,0,8,2),
  9. 2=>array(0,30,29,30,29,29,30) ,29, 30,29,30,30,30,0,9,3),
  10. 3=>array(5,29,30,29,30,29,29,30,29,29,30,30 ,29, 30,10,4),
  11. 4=>array(0,30,30,29,30,29,29,30,29,29,30,30,29,0,1,5),
  12. 5= > 配列(0,30,30,29,30,30,29,29,30,29,30,29,30,0,2,6),
  13. 6=>配列(4,29) ,30, 30,29,30,29,30,29,30,29,30,29,30,3,7),
  14. 7=>array(0,29,30,29,30,29,30) ,30, 29,30,29,30,29,0,4,8),
  15. 8=>array(0,30,29,29,30,30,29,30,29,30,30,29) ,30, 0,5,9),
  16. 9=>array(2,29,30,29,29,30,29,30,29,30,30,30,29,30,6,10),
  17. 10= > 配列(0,29,30,29,29,30,29,30,29,30,30,30,29,0,7,11),
  18. 11=>配列(6,30) ,29, 30,29,29,30,29,29,30,30,29,30,30,8,12),
  19. 12=>array(0,30,29,30,29,29,30 ,29, 29,30,30,29,30,0,9,1),
  20. 13=>array(0,30,30,29,30,29,29,30,29,29,30,29 ,30, 0,10,2),
  21. 14=>配列(5,30,30,29,30,29,30,29,30,29,30,29,29,30,1,3),
  22. 15= > 配列(0,30,29,30,30,29,30,29,30,29,30,29,30,0,2,4),
  23. 16=>配列(0,29 ,30, 29,30,29,30,30,29,30,29,30,29,0,3,5),
  24. 17=>array(2,30,29,29,30,29,30) ,30, 29,30,30,29,30,29,4,6),
  25. 18=>array(0,30,29,29,30,29,30,29,30,30,29,30 ,30, 0,5,7),
  26. 19=>array(7,29,30,29,29,30,29,29,30,30,29,30,30,30,6,8),
  27. 20= > 配列(0,29,30,29,29,30,29,29,30,30,29,30,30,0,7,9),
  28. 21=>配列(0,30 ,29, 30,29,29,30,29,29,30,29,30,30,0,8,10),
  29. 22=>array(5,30,29,30,30,29,29) ,30, 29,29,30,29,30,30,9,11),
  30. 23=>array(0,29,30,30,29,30,29,30,29,29,30,29 ,30, 0,10,12)、
  31. 24=>array(0,29,30,30,29,30,30,29,30,29,30,29,29,0,1,1),
  32. 25= > 配列(4,30,29,30,29,30,30,29,30,30,29,30,29,30,2,2),
  33. 26=>配列(0,29) ,29, 30,29,30,29,30,30,29,30,30,29,0,3,3),
  34. 27=>array(0,30,29,29,30,29,30) ,29, 30,29,30,30,30,0,4,4),
  35. 28=>array(2,29,30,29,29,30,29,29,30,29,30,30 ,30, 30,5,5)、
  36. 29=>array(0,29,30,29,29,30,29,29,30,29,30,30,30,0,6,6),
  37. 30= > 配列(6,29,30,30,29,29,30,29,29,30,29,30,30,29,7,7),
  38. 31=>配列(0,30) ,30, 29,30,29,30,29,29,30,29,30,29,0,8,8),
  39. 32=>array(0,30,30,30,29,30,29) ,30, 29,29,30,29,30,0,9,9),
  40. 33=>array(5,29,30,30,29,30,30,29,30,29,30,29 ,29, 30,10,10)、
  41. 34=>配列(0,29,30,29,30,30,29,30,29,30,30,29,30,0,1,11),
  42. 35= > 配列(0,29,29,30,29,30,29,30,30,29,30,30,29,0,2,12),
  43. 36=>配列(3,30) ,29, 29,30,29,29,30,30,29,30,30,30,29,3,1),
  44. 37=>array(0,30,29,29,30,29,29) ,30, 29,30,30,30,29,0,4,2),
  45. 38=>array(7,30,30,29,29,30,29,29,30,29,30,30 ,29, 30,5,3),
  46. 39=>配列(0,30,30,29,29,30,29,29,30,29,30,29,30,0,6,4),
  47. 40= > 配列(0,30,30,29,30,29,30,29,29,30,29,30,29,0,7,5),
  48. 41=>配列(6,30) ,30, 29,30,30,29,30,29,29,30,29,30,29,8,6),
  49. 42=>array(0,30,29,30,30,29,30 ,29, 30,29,30,29,30,0,9,7),
  50. 43=>array(0,29,30,29,30,29,30,30,29,30,29,30 ,29, 0,10,8),
  51. 44=>配列(4,30,29,30,29,30,29,30,29,30,30,29,30,30,1,9),
  52. 45= > 配列(0,29,29,30,29,29,30,29,30,30,30,29,30,0,2,10),
  53. 46=>配列(0,30) ,29, 29,30,29,29,30,29,30,30,29,30,0,3,11),
  54. 47=>array(2,30,30,29,29,30,29) ,29, 30,29,30,29,30,30,4,12),
  55. 48=>array(0,30,29,30,29,30,29,29,30,29,30,29) ,30, 0,5,1),
  56. 49=>配列(7,30,29,30,30,29,30,29,29,30,29,30,29,30,6,2),
  57. 50= > 配列(0,29,30,30,29,30,30,29,29,30,29,30,29,0,7,3),
  58. 51=>配列(0,30) ,29, 30,30,29,30,29,30,29,30,29,30,0,8,4),
  59. 52=>array(5,29,30,29,30,29,30) ,29, 30,30,29,30,29,30,9,5),
  60. 53=>array(0,29,30,29,29,30,30,29,30,30,29,30 ,29, 0,10,6),
  61. 54=>配列(0,30,29,30,29,29,30,29,30,30,29,30,30,0,1,7),
  62. 55= > 配列(3,29,30,29,30,29,29,30,29,30,29,30,30,30,2,8),
  63. 56=>配列(0,29) ,30, 29,30,29,29,30,29,30,29,30,30,0,3,9),
  64. 57=>array(8,30,29,30,29,30,29) ,29, 30,29,30,29,30,29,4,10),
  65. 58=>array(0,30,30,30,29,30,29,29,30,29,30,29) ,30, 0,5,11)、
  66. 59=>配列(0,29,30,30,29,30,29,30,29,30,29,30,29,0,6,12),
  67. 60= > 配列(6,30,29,30,29,30,30,29,30,29,30,29,30,29,7,1),
  68. 61=>配列(0,30,29,30,29,30,29,30,30,29,30,29,30,0,8,2),
  69. 62=>配列(0,29, 30,29,29,30,29,30,30,29,30,30,29,0,9,3),
  70. 63=>array(4,30,29,30,29,29,30, 29,30,29,30,30,30,29,10,4),
  71. 64=>array(0,30,29,30,29,29,30,29,30,29,30,30, 30,0,1,5)、
  72. 65=>配列(0,29,30,29,30,29,29,30,29,29,30,30,29,0,2,6),
  73. 66=>配列(3,30,30,30,29,30,29,29,30,29,29,30,30,29,3,7),
  74. 67=>配列(0,30, 30,29,30,30,29,29,30,29,30,29,30,0,4,8),
  75. 68=>array(7,29,30,29,30,30,29, 30,29,30,29,30,29,30,5,9)、
  76. 69=>array(0,29,30,29,30,29,30,30,29,30,29,30, 29,0,6,10)、
  77. 70=>array(0,30,29,29,30,29,30,30,29,30,30,29,30,0,7,11)、
  78. 71=>配列(5,29,30,29,29,30,29,30,29,30,30,30,29,30,8,12),
  79. 72=>配列(0,29, 30,29,29,30,29,30,29,30,30,29,30,0,9,1),
  80. 73=>array(0,30,29,30,29,29,30, 29,29,30,30,29,30,0,10,2),
  81. 74=>array(4,30,30,29,30,29,29,30,29,29,30,30, 29,30,1,3)、
  82. 75=>array(0,30,30,29,30,29,29,30,29,29,30,29,30,0,2,4)、
  83. 76=>配列(8,30,30,29,30,29,30,29,30,29,29,30,29,30,3,5),
  84. 77=>配列(0,30, 29,30,30,29,30,29,30,29,30,29,29,0,4,6),
  85. 78=>array(0,30,29,30,30,29,30, 30,29,30,29,30,29,0,5,7)、
  86. 79=>array(6,30,29,29,30,29,30,30,29,30,30,29, 30,29,6,8)、
  87. 80=>配列(0,30,29,29,30,29,30,29,30,30,29,30,30,0,7,9)、
  88. 81=>配列(0,29,30,29,29,30,29,29,30,30,29,30,30,0,8,10),
  89. 82=>配列(4,30, 29,30,29,29,30,29,29,30,29,30,30,30,9,11),
  90. 83=>array(0,30,29,30,29,29,30, 29,29,30,29,30,30,0,10,12)、
  91. 84=>array(10,30,29,30,30,29,29,30,29,29,30,29, 30,30,1,1)、
  92. 85=>配列(0,29,30,30,29,30,29,30,29,29,30,29,30,0,2,2),
  93. 86=>配列(0,29,30,30,29,30,30,29,30,29,30,29,29,0,3,3),
  94. 87=>配列(6,30, 29,30,29,30,30,29,30,30,29,30,29,29,4,4),
  95. 88=>array(0,30,29,30,29,30,29, 30,30,29,30,30,29,0,5,5)、
  96. 89=>array(0,30,29,29,30,29,29,30,30,29,30,30, 30,0,6,6)、
  97. 90=>array(5,29,30,29,29,30,29,29,30,29,30,30,30,30,7,7)、
  98. 91=>配列(0,29,30,29,29,30,29,29,30,29,30,30,30,0,8,8),
  99. 92=>配列(0,29, 30,30,29,29,30,29,29,30,29,30,30,0,9,9),
  100. 93=>array(3,29,30,30,29,30,29, 30,29,29,30,29,30,29,10,10)、
  101. 94=>array(0,30,30,30,29,30,29,30,29,29,30,29, 30,0,1,11)、
  102. 95=>配列(8,29,30,30,29,30,29,30,30,29,29,30,29,30,2,12),
  103. 96=>配列(0,29,30,29,30,30,29,30,29,30,30,29,29,0,3,1),
  104. 97=>配列(0,30, 29,30,29,30,29,30,30,29,30,30,29,0,4,2),
  105. 98=>array(5,30,29,29,30,29,29, 30,30,29,30,30,29,30,5,3)、
  106. 99=>array(0,30,29,29,30,29,29,30,29,30,30,30, 29,0,6,4)、
  107. 100=>配列(0,30,30,29,29,30,29,29,30,29,30,30,29,0,7,5)、
  108. 101=>配列(4,30,30,29,30,29,30,29,29,30,29,30,29,30,8,6),
  109. 102=>配列(0,30, 30,29,30,29,30,29,29,30,29,30,29,0,9,7),
  110. 103=>array(0,30,30,29,30,30,29, 30,29,29,30,29,30,0,10,8)、
  111. 104=>array(2,29,30,29,30,30,29,30,29,30,29,30, 29,30,1,9)、
  112. 105=>配列(0,29,30,29,30,29,30,30,29,30,29,30,29,0,2,10),
  113. 106=>配列(7,30,29,30,29,30,29,30,29,30,30,29,30,30,3,11),
  114. 107=>配列(0,29, 29,30,29,29,30,29,30,30,30,29,30,0,4,12),
  115. 108=>array(0,30,29,29,30,29,29, 30,29,30,30,29,30,0,5,1),
  116. 109=>array(5,30,30,29,29,30,29,29,30,29,30,29, 30,30,6,2)、
  117. 110=>配列(0,30,29,30,29,30,29,29,30,29,30,29,30,0,7,3),
  118. 111=>配列(0,30,29,30,30,29,30,29,29,30,29,30,29,0,8,4),
  119. 112=>配列(4,30, 29,30,30,29,30,29,30,29,30,29,30,29,9,5),
  120. 113=>array(0,30,29,30,29,30,30, 29,30,29,30,29,30,0,10,6)、
  121. 114=>array(9,29,30,29,30,29,30,29,30,30,29,30, 29,30,1,7)、
  122. 115=>array(0,29,30,29,29,30,29,30,30,30,29,30,29,0,2,8)、
  123. 116=>配列(0,30,29,30,29,29,30,29,30,30,29,30,30,0,3,9),
  124. 117=>配列(6,29, 30,29,30,29,29,30,29,30,29,30,30,30,4,10),
  125. 118=>array(0,29,30,29,30,29,29, 30,29,30,29,30,30,0,5,11)、
  126. 119=>array(0,30,29,30,29,30,29,29,30,29,29,30, 30,0,6,12),
  127. 120=>array(4,29,30,30,30,29,30,29,29,30,29,30,29,30,7,1)
  128. ) ;
  129. ##----------
  130. #农历天干
  131. var $mten=array("null","甲","乙","丙","丁","戊","己"、"庚"、"辛"、"壬"、"癸"); #农历地支
  132. var $mtwelve=array("null","子(ネズミ)","チョウ(牛)","陰(トラ)","卯(ウサギ)","陳(龍)","巳(ヘビ) ","Wu(馬)","Wei(羊)","Shen(猿)","You(鶏)","Xu(犬)","Hai(豚)"); #旧月
  133. var $mmonth=array("闰","正","二","三","四","五","六","七","八","九","十"," 11","12","月");
  134. var $mday=array("null","中学校1日目","中学校2日目","中学校3日目", 「中学4日」、「中学5日」、「旧月6日」、「旧月7日」、「旧月8日」、「陰暦 9 日」、「陰陰月 10 日」、「11 日」、「12 日」、「13 日」、「14 日」、「15 日」、「16 日」、「17 日」、「18 日」、 「19」、「20」、「21」、「22」、「23」、「24」、「25」、「26」、「27」、 "28", "29", "30");#lunarday
  135. ##-----------
  136. #初期値を割り当てる
  137. #天の茎と地上の枝
  138. var $ten = 0;
  139. var $twelve = 0;
  140. function MyPub($c Year, $cMonth, $cDay){
  141. $total = 11; #1900 年 12 月 21 日までの合計日数
  142. $ mtotal = 0; #旧暦の合計日数
  143. for ($y = 1901; $y < $c Year; $y++){
  144. $total += 365;
  145. if ($y % 4 == 0){
  146. $total++ ;
  147. }
  148. }
  149. #今年の月を追加します
  150. switch ($cMonth){
  151. case 12:
  152. $total += 30;
  153. case 10:
  154. $total + = 30;
  155. ケース 9:
  156. $total += 31;
  157. ケース 7:
  158. $total += 31; 5 :
  159. $total += 30;
  160. ケース 4:
  161. $total += 28;
  162. ケース 2:
  163. $total += 31;は閏年ですが、1 日追加します
  164. if ($cyear % 4 == 0 and $cMonth > 2){
  165. $total++ }
  166. $total += $cDay - 1;
  167. ##---- ------ --
  168. #太陰暦の累積日数を使用して、太陽暦の日数を超えているかどうかを判断します
  169. for ($j = 0; $j $i = 1;
  170. for ($i = 1; $ i $mtotal += $this->everyCMonth[$j][$i];
  171. if ( $mtotal >= $total){
  172. $flag = 1;
  173. }
  174. }
  175. if ($flag == 1){
  176. }
  177. }
  178. return array("m" => $ j, "d" => $i, "t" => $total, "n" => $mtotal);
  179. 関数 Cal($year, $Month, $Day){
  180. $Par = $this->MyPub($ Year, $Month, $Day);
  181. $md = $this->everyCMonth[$Par["m"]][$Par["d"]] - ($Par[ "n"] - $Par["t"]);
  182. $week = ($Par["t"] + 5) % 7;
  183. if ($this->everyCMonth[$Par["m"]] [0] <> 0 および $this->everyCMonth[$ Par["m"]][0] <$Par["d"]){
  184. $mm = $Par["d"] - 1;
  185. }else{
  186. $mm = $Par["d"] ;
  187. }
  188. if ($Par["d"] == $this->everyCMonth[$Par["d"]][0] + 1 と $this->everyCMonth[$Par["d"] ][0] <> 0){
  189. $cMonth = $this->mmonth[0].$this->mmonth[$ mm]; #閏月
  190. }
  191. else{
  192. $cMonth = $this->mmonth[$mm].$this->mmonth[13];
  193. return array("year" => $this ->mten[$this->everyCMonth[$Par["m" ]][14]].$this->mtwelve[$this->everyCMonth[$Par["m"]][15] ], "month" => $cMonth, "day" => $ this->mday[$md], "week" => $week);
  194. }
  195. }
  196. //呼び出し例
  197. $test = 新しいカレンダー;
  198. $year = $test->Cal(2004, 2, 20);
  199. echo $ Year["year"]."year".$ Year["month"].$ Year["day" ]."週".$年["週"]
  200. ?> ;
  201. コードをコピー


関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート