when_exe 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. data/bin/irb.rc +1 -0
  2. data/bin/locales.rb +8 -6
  3. data/bin/when.rb +1 -1
  4. data/lib/when_exe.rb +231 -146
  5. data/lib/when_exe/basictypes.rb +108 -18
  6. data/lib/when_exe/calendarnote.rb +263 -116
  7. data/lib/when_exe/calendartypes.rb +413 -22
  8. data/lib/when_exe/coordinates.rb +58 -36
  9. data/lib/when_exe/core/compatibility.rb +8 -6
  10. data/lib/when_exe/core/extension.rb +40 -15
  11. data/lib/when_exe/ephemeris.rb +20 -19
  12. data/lib/when_exe/{region → ephemeris}/moon.rb +4 -4
  13. data/lib/when_exe/{region/ephemeric_notes.rb → ephemeris/notes.rb} +25 -6
  14. data/lib/when_exe/{region → ephemeris}/planets.rb +0 -0
  15. data/lib/when_exe/{region → ephemeris}/sun.rb +7 -3
  16. data/lib/when_exe/{region → ephemeris}/v50.rb +0 -0
  17. data/lib/when_exe/googlecalendar.rb +2 -2
  18. data/lib/when_exe/icalendar.rb +3 -3
  19. data/lib/when_exe/inspect.rb +130 -70
  20. data/lib/when_exe/locales/af.rb +2 -2
  21. data/lib/when_exe/locales/akt.rb +176 -0
  22. data/lib/when_exe/locales/ar.rb +2 -2
  23. data/lib/when_exe/locales/{locales.rb → autoload.rb} +6 -2
  24. data/lib/when_exe/locales/az.rb +2 -2
  25. data/lib/when_exe/locales/bg.rb +2 -2
  26. data/lib/when_exe/locales/bn.rb +2 -2
  27. data/lib/when_exe/locales/bs.rb +2 -2
  28. data/lib/when_exe/locales/ca.rb +2 -2
  29. data/lib/when_exe/locales/cs.rb +2 -2
  30. data/lib/when_exe/locales/cy.rb +2 -2
  31. data/lib/when_exe/locales/da.rb +2 -2
  32. data/lib/when_exe/locales/de.rb +2 -2
  33. data/lib/when_exe/locales/de_AT.rb +2 -2
  34. data/lib/when_exe/locales/de_CH.rb +2 -2
  35. data/lib/when_exe/locales/el.rb +2 -2
  36. data/lib/when_exe/locales/en.rb +2 -2
  37. data/lib/when_exe/locales/en_AU.rb +2 -2
  38. data/lib/when_exe/locales/en_CA.rb +2 -2
  39. data/lib/when_exe/locales/en_GB.rb +2 -2
  40. data/lib/when_exe/locales/en_IE.rb +2 -2
  41. data/lib/when_exe/locales/en_IN.rb +3 -3
  42. data/lib/when_exe/locales/en_NZ.rb +2 -2
  43. data/lib/when_exe/locales/en_US.rb +2 -2
  44. data/lib/when_exe/locales/en_ZA.rb +88 -0
  45. data/lib/when_exe/locales/encoding_conversion.rb +126 -0
  46. data/lib/when_exe/locales/eo.rb +2 -2
  47. data/lib/when_exe/locales/es.rb +2 -2
  48. data/lib/when_exe/locales/es_419.rb +2 -2
  49. data/lib/when_exe/locales/es_AR.rb +2 -2
  50. data/lib/when_exe/locales/es_CL.rb +2 -2
  51. data/lib/when_exe/locales/es_CO.rb +2 -2
  52. data/lib/when_exe/locales/es_CR.rb +2 -2
  53. data/lib/when_exe/locales/es_EC.rb +2 -2
  54. data/lib/when_exe/locales/es_MX.rb +2 -2
  55. data/lib/when_exe/locales/es_PA.rb +2 -2
  56. data/lib/when_exe/locales/es_PE.rb +2 -2
  57. data/lib/when_exe/locales/es_US.rb +84 -0
  58. data/lib/when_exe/locales/es_VE.rb +2 -2
  59. data/lib/when_exe/locales/et.rb +2 -2
  60. data/lib/when_exe/locales/eu.rb +2 -2
  61. data/lib/when_exe/locales/fa.rb +2 -2
  62. data/lib/when_exe/locales/fi.rb +3 -3
  63. data/lib/when_exe/locales/fr.rb +2 -2
  64. data/lib/when_exe/locales/fr_CA.rb +2 -2
  65. data/lib/when_exe/locales/fr_CH.rb +2 -2
  66. data/lib/when_exe/locales/gl.rb +2 -2
  67. data/lib/when_exe/locales/he.rb +3 -3
  68. data/lib/when_exe/locales/hi.rb +2 -2
  69. data/lib/when_exe/locales/hi_IN.rb +2 -2
  70. data/lib/when_exe/locales/hr.rb +2 -2
  71. data/lib/when_exe/locales/hu.rb +6 -5
  72. data/lib/when_exe/locales/iast.rb +90 -0
  73. data/lib/when_exe/locales/id.rb +2 -2
  74. data/lib/when_exe/locales/is.rb +2 -2
  75. data/lib/when_exe/locales/it.rb +2 -2
  76. data/lib/when_exe/locales/it_CH.rb +2 -2
  77. data/lib/when_exe/locales/ja.rb +2 -2
  78. data/lib/when_exe/locales/kn.rb +2 -2
  79. data/lib/when_exe/locales/ko.rb +2 -2
  80. data/lib/when_exe/locales/links.rb +3 -3
  81. data/lib/when_exe/locales/lo.rb +2 -2
  82. data/lib/when_exe/{parts → locales}/locale.rb +77 -49
  83. data/lib/when_exe/locales/lt.rb +6 -2
  84. data/lib/when_exe/locales/lv.rb +2 -2
  85. data/lib/when_exe/locales/mk.rb +2 -2
  86. data/lib/when_exe/locales/mn.rb +2 -2
  87. data/lib/when_exe/locales/ms.rb +2 -2
  88. data/lib/when_exe/locales/nb.rb +2 -2
  89. data/lib/when_exe/locales/ne.rb +2 -2
  90. data/lib/when_exe/locales/nl.rb +2 -2
  91. data/lib/when_exe/locales/nn.rb +2 -2
  92. data/lib/when_exe/locales/or.rb +2 -2
  93. data/lib/when_exe/locales/pl.rb +2 -2
  94. data/lib/when_exe/locales/pt.rb +2 -2
  95. data/lib/when_exe/locales/pt_BR.rb +2 -2
  96. data/lib/when_exe/locales/rm.rb +2 -2
  97. data/lib/when_exe/locales/ro.rb +2 -2
  98. data/lib/when_exe/locales/ru.rb +2 -2
  99. data/lib/when_exe/locales/sk.rb +2 -2
  100. data/lib/when_exe/locales/sl.rb +2 -2
  101. data/lib/when_exe/locales/sr.rb +2 -2
  102. data/lib/when_exe/locales/sv.rb +2 -2
  103. data/lib/when_exe/locales/sw.rb +2 -2
  104. data/lib/when_exe/locales/ta.rb +95 -0
  105. data/lib/when_exe/locales/th.rb +2 -2
  106. data/lib/when_exe/locales/tl.rb +3 -3
  107. data/lib/when_exe/locales/tr.rb +2 -2
  108. data/lib/when_exe/locales/transliteration_table.rb +62 -0
  109. data/lib/when_exe/locales/uk.rb +15 -15
  110. data/lib/when_exe/locales/ur.rb +2 -2
  111. data/lib/when_exe/locales/uz.rb +2 -2
  112. data/lib/when_exe/locales/vi.rb +2 -2
  113. data/lib/when_exe/locales/wo.rb +2 -2
  114. data/lib/when_exe/locales/zh_CN.rb +2 -2
  115. data/lib/when_exe/locales/zh_HK.rb +15 -15
  116. data/lib/when_exe/locales/zh_TW.rb +2 -2
  117. data/lib/when_exe/locales/zh_YUE.rb +77 -0
  118. data/lib/when_exe/mini_application.rb +22 -12
  119. data/lib/when_exe/parts/geometric_complex.rb +16 -1
  120. data/lib/when_exe/parts/method_cash.rb +184 -238
  121. data/lib/when_exe/parts/resource.rb +65 -16
  122. data/lib/when_exe/region/armenian.rb +56 -0
  123. data/lib/when_exe/region/bahai.rb +13 -13
  124. data/lib/when_exe/region/balinese.rb +33 -35
  125. data/lib/when_exe/region/chinese.rb +82 -78
  126. data/lib/when_exe/region/{chinese_calendar.rb → chinese/calendars.rb} +59 -40
  127. data/lib/when_exe/region/{chinese_epoch.rb → chinese/epochs.rb} +3 -4
  128. data/lib/when_exe/region/{chinese_twin.rb → chinese/twins.rb} +48 -51
  129. data/lib/when_exe/region/christian.rb +236 -127
  130. data/lib/when_exe/region/coptic.rb +9 -10
  131. data/lib/when_exe/region/dee.rb +48 -0
  132. data/lib/when_exe/region/discordian.rb +225 -0
  133. data/lib/when_exe/region/far_east.rb +2 -6
  134. data/lib/when_exe/region/french.rb +7 -17
  135. data/lib/when_exe/region/geologicalage.rb +0 -1
  136. data/lib/when_exe/region/goddess.rb +58 -0
  137. data/lib/when_exe/region/indian.rb +323 -231
  138. data/lib/when_exe/region/iranian.rb +159 -22
  139. data/lib/when_exe/region/islamic.rb +7 -9
  140. data/lib/when_exe/region/japanese.rb +14 -803
  141. data/lib/when_exe/region/japanese/calendars.rb +397 -0
  142. data/lib/when_exe/region/japanese/epochs.rb +426 -0
  143. data/lib/when_exe/region/{nihon_shoki.rb → japanese/nihon_shoki.rb} +0 -2
  144. data/lib/when_exe/region/{japanese_notes.rb → japanese/notes.rb} +179 -150
  145. data/lib/when_exe/region/japanese/residues.rb +1306 -0
  146. data/lib/when_exe/region/{japanese_twin.rb → japanese/twins.rb} +12 -15
  147. data/lib/when_exe/region/javanese.rb +16 -14
  148. data/lib/when_exe/region/jewish.rb +8 -9
  149. data/lib/when_exe/region/korean.rb +146 -35
  150. data/lib/when_exe/region/m17n.rb +8 -10
  151. data/lib/when_exe/region/martian.rb +44 -16
  152. data/lib/when_exe/region/mayan.rb +12 -10
  153. data/lib/when_exe/region/pope.rb +0 -1
  154. data/lib/when_exe/region/residue.rb +4 -5
  155. data/lib/when_exe/region/roman.rb +20 -24
  156. data/lib/when_exe/region/ryukyu.rb +3 -4
  157. data/lib/when_exe/region/shire.rb +97 -94
  158. data/lib/when_exe/region/symmetry.rb +50 -0
  159. data/lib/when_exe/region/thai.rb +164 -56
  160. data/lib/when_exe/region/tibetan.rb +86 -86
  161. data/lib/when_exe/region/vietnamese.rb +9 -12
  162. data/lib/when_exe/region/weekdate.rb +80 -0
  163. data/lib/when_exe/region/world.rb +65 -70
  164. data/lib/when_exe/region/yerm.rb +98 -0
  165. data/lib/when_exe/region/zoroastrian.rb +203 -0
  166. data/lib/when_exe/timestandard.rb +4 -4
  167. data/lib/when_exe/tmobjects.rb +1 -3
  168. data/lib/when_exe/tmposition.rb +13 -12
  169. data/lib/when_exe/tmreference.rb +11 -10
  170. data/lib/when_exe/version.rb +1 -1
  171. data/link_to_online_documents +3 -3
  172. data/test/examples/Residue.m17n +1 -1
  173. data/test/examples/Terms.m17n +1 -1
  174. data/test/test.rb +2 -1
  175. data/test/test/basictypes.rb +18 -2
  176. data/test/test/calendarnote.rb +1 -1
  177. data/test/test/calendartypes.rb +1 -1
  178. data/test/test/coordinates.rb +7 -7
  179. data/test/test/{region → ephemeris}/moon.rb +0 -0
  180. data/test/test/{region → ephemeris}/planets.rb +0 -0
  181. data/test/test/{region → ephemeris}/sun.rb +0 -0
  182. data/test/test/parts.rb +8 -13
  183. data/test/test/region/christian.rb +245 -0
  184. data/test/test/region/french.rb +16 -16
  185. data/test/test/region/iran.rb +34 -34
  186. data/test/test/region/japanese.rb +6 -4
  187. data/test/test/region/m17n.rb +8 -7
  188. data/test/test/region/mayan.rb +12 -12
  189. data/test/test/region/residue.rb +20 -4
  190. data/test/test/region/thai.rb +25 -3
  191. data/test/test/region/yerm.rb +146 -0
  192. metadata +39 -20
  193. data/lib/when_exe/region/japanese_residues.rb +0 -1212
  194. data/test/test/region/civil.rb +0 -124
@@ -9,80 +9,78 @@ module When
9
9
 
10
10
  class BasicTypes::M17n
11
11
 
12
- ChineseTerms = [self, [
13
- "namespace:[en=http://en.wikipedia.org/wiki/, ja=http://ja.wikipedia.org/wiki/]",
12
+ Chinese = [self, [
14
13
  "locale:[=ja:, en=en:, alias]",
15
- "names:[ChineseTerms=]",
14
+ "names:[Chinese=]",
16
15
  "[中国太陽暦(節月)=ja:%%<二十四節気>#%.<暦月と節月>, *ChineseSolar=en:Solar_term]",
17
16
  "[中国太陰太陽暦=ja:%%<中国暦>, *ChineseLuniSolar=en:Chinese_calendar]",
18
17
  "[彝暦=ja:%%<イ族>, *Yi=en:Yi_people]",
19
18
 
20
19
  [self,
21
20
  "names:[月=ja:%%<月_(暦)>, *Month]",
22
- "[正月, 1st Month= ]",
23
- "[二月, 2nd Month= ]",
24
- "[三月, 3rd Month= ]",
25
- "[四月, 4th Month= ]",
26
- "[五月, 5th Month= ]",
27
- "[六月, 6th Month= ]",
28
- "[七月, 7th Month= ]",
29
- "[八月, 8th Month= ]",
30
- "[九月, 9th Month= ]",
31
- "[十月, 10th Month=]",
32
- "[十一月, 11th Month=]",
33
- "[十二月, 12th Month=]"
21
+ "[正月, Month 1= ]",
22
+ "[二月, Month 2= ]",
23
+ "[三月, Month 3= ]",
24
+ "[四月, Month 4= ]",
25
+ "[五月, Month 5= ]",
26
+ "[六月, Month 6= ]",
27
+ "[七月, Month 7= ]",
28
+ "[八月, Month 8= ]",
29
+ "[九月, Month 9= ]",
30
+ "[十月, Month 10=]",
31
+ "[十一月, Month 11=]",
32
+ "[十二月, Month 12=]"
34
33
  ],
35
34
 
36
35
  [self,
37
36
  "names:[月=ja:%%<月_(暦)>, *MonthA]",
38
- "[一月, 1st Month= ]",
39
- "[二月, 2nd Month= ]",
40
- "[三月, 3rd Month= ]",
41
- "[四月, 4th Month= ]",
42
- "[五月, 5th Month= ]",
43
- "[六月, 6th Month= ]",
44
- "[七月, 7th Month= ]",
45
- "[八月, 8th Month= ]",
46
- "[九月, 9th Month= ]",
47
- "[十月, 10th Month=]",
37
+ "[一月, Month 1= ]",
38
+ "[二月, Month 2= ]",
39
+ "[三月, Month 3= ]",
40
+ "[四月, Month 4= ]",
41
+ "[五月, Month 5= ]",
42
+ "[六月, Month 6= ]",
43
+ "[七月, Month 7= ]",
44
+ "[八月, Month 8= ]",
45
+ "[九月, Month 9= ]",
46
+ "[十月, Month 10=]",
48
47
  "[正月, New Year Month=]",
49
- "[臘月, 12th Month=]"
48
+ "[臘月, Month 12=]"
50
49
  ],
51
50
 
52
51
  [self,
53
52
  "names:[月=ja:%%<月_(暦)>, *MonthB]",
54
- "[建寅月, 3rd Month= ]",
55
- "[建卯月, 4th Month= ]",
56
- "[建辰月, 5th Month= ]",
57
- "[建巳月, 6th Month= ]",
58
- "[建午月, 7th Month= ]",
59
- "[建未月, 8th Month= ]",
60
- "[建申月, 9th Month= ]",
61
- "[建酉月, 10th Month ]",
62
- "[建戌月, 11th Month ]",
63
- "[建亥月, 12th Month=]",
64
- "[建子月, 1st Month= ]",
65
- "[建丑月, 2nd Month= ]"
53
+ "[建寅月, Month 3= ]",
54
+ "[建卯月, Month 4= ]",
55
+ "[建辰月, Month 5= ]",
56
+ "[建巳月, Month 6= ]",
57
+ "[建午月, Month 7= ]",
58
+ "[建未月, Month 8= ]",
59
+ "[建申月, Month 9= ]",
60
+ "[建酉月, Month 10=]",
61
+ "[建戌月, Month 11=]",
62
+ "[建亥月, Month 12=]",
63
+ "[建子月, Month 1= ]",
64
+ "[建丑月, Month 2= ]"
66
65
  ]
67
66
  ]]
68
67
 
69
- YiTerms = [self, [
70
- "namespace:[en=http://en.wikipedia.org/wiki/, ja=http://ja.wikipedia.org/wiki/]",
68
+ Yi = [self, [
71
69
  "locale:[=ja:, en=en:, alias]",
72
- "names:[YiTerms=]",
70
+ "names:[Yi=]",
73
71
 
74
72
  [self,
75
73
  "names:[月=ja:%%<月_(暦)>, *Month]",
76
- "[木公月, 1st Month= ]",
77
- "[木母月, 2nd Month= ]",
78
- "[火公月, 3rd Month= ]",
79
- "[火母月, 4th Month= ]",
80
- "[土公月, 5th Month= ]",
81
- "[土母月, 6th Month= ]",
82
- "[銅公月, 7th Month= ]",
83
- "[銅母月, 8th Month= ]",
84
- "[水公月, 9th Month= ]",
85
- "[水母月, 10th Month=]",
74
+ "[木公月, Month 1= ]",
75
+ "[木母月, Month 2= ]",
76
+ "[火公月, Month 3= ]",
77
+ "[火母月, Month 4= ]",
78
+ "[土公月, Month 5= ]",
79
+ "[土母月, Month 6= ]",
80
+ "[銅公月, Month 7= ]",
81
+ "[銅母月, Month 8= ]",
82
+ "[水公月, Month 9= ]",
83
+ "[水母月, Month 10=]",
86
84
  "[過年日, end of year days=]"
87
85
  ]
88
86
  ]]
@@ -92,7 +90,6 @@ module When
92
90
 
93
91
  # Yi years
94
92
  Yi = [When::BasicTypes::M17n, [
95
- "namespace:[en=http://en.wikipedia.org/wiki/, ja=http://ja.wikipedia.org/wiki/]",
96
93
  "locale:[=ja:, en=en:, alias]",
97
94
  "names:[Yi]",
98
95
 
@@ -110,6 +107,10 @@ module When
110
107
  ]]
111
108
  end
112
109
 
110
+ class CalendarNote
111
+ Yis = [['Yi::YearName'], ['_m:Calendar::Month'], ['Common::Week']]
112
+ end
113
+
113
114
  module Ephemeris
114
115
 
115
116
  #
@@ -139,10 +140,6 @@ module When
139
140
  # 近点月
140
141
  @anomalistic_month_length = @anomalistic_month_length.to_r
141
142
 
142
- # 通法
143
- @denominator = @year_length.denominator if @year_length.kind_of?(Rational)
144
- @denominator = [@denominator||0, @lunation_length.denominator].max if @lunation_length.kind_of?(Rational)
145
-
146
143
  # 計算式 C) のための繰り返し回数
147
144
  @repeat_count ||= @method.upcase == 'C' ? 2 : 1
148
145
  @repeat_count = @repeat_count.to_i
@@ -184,7 +181,7 @@ module When
184
181
  end
185
182
  end
186
183
 
187
- # 戊寅暦 立成 1次補間
184
+ # 戊寅元暦 立成 1次補間
188
185
  def _rissei_a(k)
189
186
  tv = [0,1].map {|i| _tv_s(k+i)}
190
187
  [(tv[1][1]-tv[0][1]) / (tv[1][0]-tv[0][0]), 0.0]
@@ -615,7 +612,7 @@ module When
615
612
  return super unless @cycle_number_1m
616
613
  time = @is_dynamical ? +t : t.to_f
617
614
  cn0 = time * @cycle_number_1m + @cycle_number_0m
618
- root(cn0, time) {|cn| cn_to_time(cn)}
615
+ root(cn0, time, 0, 5) {|cn| cn_to_time(cn)}
619
616
  end
620
617
 
621
618
  # 当該日付の月の位相の変化範囲(唐代の定朔の暦法用 cn_to_time(1L) を使用する)
@@ -633,7 +630,10 @@ module When
633
630
  loop do
634
631
  t0 = cn_to_time( c / 60.0)
635
632
  t1 = cn_to_time((c+1)/ 60.0)
636
- if t0 > t
633
+ d = ((t-t0) / (t1-t0)).round
634
+ if d.abs > 1
635
+ c += d
636
+ elsif t0 > t
637
637
  c -= 1
638
638
  elsif t1 <= t
639
639
  c += 1
@@ -650,26 +650,31 @@ module When
650
650
  # オブジェクトの正規化
651
651
  def _normalize(args=[], options={})
652
652
  super
653
+
654
+ # 通法
655
+ @denominator = @year_length.denominator if @year_length.kind_of?(Rational)
656
+ @denominator = [@denominator||0, @lunation_length.denominator].max if @lunation_length.kind_of?(Rational)
657
+
653
658
  if @formula == '1L'
654
659
 
655
660
  # 月の位相の計算
656
661
  @method ||= @year_span ? 'J' : 'A'
657
- instance_eval("class << self; include const_get('Method#{@method.upcase}'); end")
662
+ extend self.class.const_get("Method#{@method.upcase}")
658
663
 
659
664
  # 立成の初期化
660
665
  _initialize_rissei
661
666
 
662
667
  elsif @year_span
663
668
  # 太陽黄経の計算(消長あり)
664
- class << self; include MethodS; end
669
+ extend MethodS
665
670
  @year_span = @year_span.to_i
666
671
  end
667
672
 
668
673
  if self.kind_of?(JujiMethods)
669
674
  case @year_span
670
- when 0,1; class << self; include JujiMethods::Y; end
671
- # when 10 ; class << self; include JujiMethods::D; end
672
- else ; class << self; include JujiMethods::C; end
675
+ when 0,1; extend JujiMethods::Y
676
+ # when 10 ; extend JujiMethods::D
677
+ else ; extend JujiMethods::C
673
678
  end
674
679
  end
675
680
  end
@@ -734,15 +739,15 @@ module When
734
739
  # @formula = 太陽黄経の計算に用いるEphemeris
735
740
  #
736
741
  def _normalize(args=[], options={})
737
- @label ||= When.Resource('_m:ChineseTerms::ChineseSolar')
742
+ @label ||= 'Chinese::ChineseSolar'
738
743
  @formula ||= ['Formula']
739
744
  @formula = Array(@formula)
740
745
  @formula *= 2 if @formula.length == 1
741
746
  @formula[0] += (@formula[0] =~ /\?/ ? '&' : '?') + 'formula=12S' if @formula[0].kind_of?(String)
742
747
  @formula[1] += (@formula[1] =~ /\?/ ? '&' : '?') + 'formula=1L' if @formula[1].kind_of?(String)
743
- @note ||= When.CalendarNote('ChineseNotes')
748
+ @note ||= When.CalendarNote('Chinese')
744
749
  @indices ||= [
745
- When::Coordinates::Index.new({:trunk=>When.Resource('_m:ChineseTerms::Month::*')}),
750
+ When.Index('Chinese::Month'),
746
751
  When::Coordinates::DefaultDayIndex
747
752
  ]
748
753
  super
@@ -787,7 +792,7 @@ module When
787
792
  # @formula = 太陽黄経および月の位相の計算に用いるEphemeris
788
793
  #
789
794
  def _normalize(args=[], options={})
790
- @label ||= When.Resource('_m:ChineseTerms::ChineseLuniSolar')
795
+ @label ||= 'Chinese::ChineseLuniSolar'
791
796
  @formula ||= ['Formula']
792
797
  @formula = Array(@formula)
793
798
  @formula *= 2 if @formula.length == 1
@@ -799,10 +804,9 @@ module When
799
804
  @intercalary_span ||= 12
800
805
  @intercalary_span = @intercalary_span.to_i
801
806
  @intercalary_month = (@intercalary_month.to_i - @base_month) % 12 + 1 if @intercalary_month
802
- @note ||= When.CalendarNote('ChineseNotes')
807
+ @note ||= When.CalendarNote('Chinese')
803
808
  @indices ||= [
804
- When::Coordinates::Index.new({:branch=>{1=>When.Resource('_m:CalendarTerms::閏')},
805
- :trunk=>When.Resource('_m:ChineseTerms::Month::*')}),
809
+ When.Index('Chinese::Month', {:branch=>{1=>'_m:Calendar::閏'}}),
806
810
  When::Coordinates::DefaultDayIndex
807
811
  ]
808
812
  super
@@ -908,7 +912,7 @@ module When
908
912
  'origin_of_LSC' => 2397523,
909
913
  'origin_of_MSC' => 1852,
910
914
  'indices' => [
911
- When::Coordinates::Index.new({:unit =>12, :trunk=>When.Resource('_m:ChineseTerms::Month::*')}),
915
+ When.Index('Chinese::Month', {:unit =>12}),
912
916
  When::Coordinates::DefaultDayIndex
913
917
  ],
914
918
  'rule_table' => {
@@ -924,25 +928,25 @@ module When
924
928
  'origin_of_LSC' => 2397522,
925
929
  'origin_of_MSC' => 1852,
926
930
  'indices' => [
927
- When::Coordinates::Index.new({:unit =>12, :trunk=>When.Resource('_m:ChineseTerms::Month::*')}),
928
- When::Coordinates::Index.new({:shift => 1})
931
+ When.Index('Chinese::Month', {:unit =>12}),
932
+ When.Index({:shift => 1})
929
933
  ],
930
934
  'rule_table' => {
931
935
  'T' => {'Rule' =>[366]},
932
936
  366 => {'Length'=>[31,30]*6}
933
937
  },
934
- 'note' => 'DefaultNotes'
938
+ 'note' => 'Default'
935
939
  }]
936
940
 
937
941
  #
938
942
  # 彝
939
943
  #
940
944
  Yi = [CyclicTableBased, {
941
- 'label' => When.Resource('_m:ChineseTerms::Yi'),
945
+ 'label' => 'Chinese::Yi',
942
946
  'origin_of_LSC' => 1721431,
943
947
  'origin_of_MSC' => 1,
944
948
  'indices' => [
945
- When::Coordinates::Index.new({:unit =>11, :trunk=>When.Resource('_m:YiTerms::Month::*')}),
949
+ When.Index('Yi::Month', {:unit =>11}),
946
950
  When::Coordinates::DefaultDayIndex
947
951
  ],
948
952
  'rule_table' => {
@@ -950,7 +954,7 @@ module When
950
954
  365 => {'Length'=>[36]*10 + [5]},
951
955
  366 => {'Length'=>[36]*10 + [6]}
952
956
  },
953
- 'note' => 'YiNotes'
957
+ 'note' => 'Yis'
954
958
  }]
955
959
  end
956
960
  end
@@ -10,29 +10,28 @@ require 'when_exe/region/chinese'
10
10
  module When
11
11
  module CalendarTypes
12
12
 
13
- _IndicesM1 = [
14
- Coordinates::Index.new({:branch=>{1=>When.Resource('_m:CalendarTerms::閏')},
15
- :trunk=>When.Resource('_m:ChineseTerms::Month::*')}),
16
- Coordinates::DefaultDayIndex
13
+ # @private
14
+ ChineseIndices = [
15
+ When.Index('Chinese::Month', {:branch=>{1=>'_m:Calendar::閏'}}),
16
+ When::Coordinates::DefaultDayIndex
17
17
  ]
18
18
 
19
19
  _IndicesM12 = [
20
- Coordinates::Index.new({:branch=>{1=>When.Resource('_m:CalendarTerms::閏')},
21
- :trunk=>When.Resource('_m:ChineseTerms::Month::*'), :shift=>1}),
22
- Coordinates::DefaultDayIndex
20
+ When.Index('Chinese::Month', {:branch=>{1=>'_m:Calendar::閏'}, :shift=>1}),
21
+ When::Coordinates::DefaultDayIndex
23
22
  ]
24
23
 
25
24
  _IndicesM11 = [
26
- Coordinates::Index.new({:branch=>{1=>When.Resource('_m:CalendarTerms::閏')},
27
- :trunk=>When.Resource('_m:ChineseTerms::Month::*'), :shift=>2}),
28
- Coordinates::DefaultDayIndex
25
+ When.Index('Chinese::Month', {:branch=>{1=>'_m:Calendar::閏'}, :shift=>2}),
26
+ When::Coordinates::DefaultDayIndex
29
27
  ]
30
28
 
31
- # 秦・漢:: 顓頊暦 -221 - -162 (冬至を11月に固定) (歳首 建亥月)
29
+ # 秦・漢:: 顓頊暦 -221 - -162 (冬至を11月に固定) (歳首 建亥月)
32
30
  # 漢:: 顓頊暦 -161 - -103 (雨水を1月に固定) (歳首 建亥月)
33
31
  Chinese_221 = [PatternTableBasedLuniSolar, {
34
32
  'origin_of_MSC'=>-222, 'origin_of_LSC'=>1640021, 'border'=>'0*10-01',
35
- 'indices'=> _IndicesM1,
33
+ 'before' => 'ChineseTwin::顓頊暦', 'after' => 'Chinese_103',
34
+ 'indices'=> ChineseIndices,
36
35
  'rule_table'=> %w(
37
36
  AbCdEfGhIjKl ABcDeFgHiJkL aBcDeFGhIiJkL
38
37
  aBcDeFgHiJKl AbCdEfGhIjKl ABcDeFgHiIjKl AbCdEFgHiJkL aBcDeFgHIiJkL
@@ -69,7 +68,8 @@ module When
69
68
  # 蜀漢:: 四分暦 221 - 264
70
69
  Chinese_103 = [PatternTableBasedLuniSolar, {
71
70
  'origin_of_MSC'=>-103, 'origin_of_LSC'=>1683490,
72
- 'indices'=> _IndicesM1,
71
+ 'before' => 'Chinese_221', 'after' => 'Chinese0239',
72
+ 'indices'=> ChineseIndices,
73
73
  'rule_table'=> %w(
74
74
  ABcdeFgHiJkL aBCdEfGhIjKl AbCdEfFGhIjKl AbCdEfGhIJkL
75
75
 
@@ -159,6 +159,7 @@ module When
159
159
  # 新:: 太初暦 7 - 23 (歳首 建丑月)
160
160
  Chinese0008 = [PatternTableBasedLuniSolar, {
161
161
  'origin_of_MSC'=>7, 'origin_of_LSC'=>1723652, 'border'=>'0*12-01',
162
+ 'before' => 'Chinese_103', 'after' => 'Chinese_103',
162
163
  'indices'=> _IndicesM12,
163
164
  'rule_table'=> %w(
164
165
  aBcDeFgHiJkL aABcDeFgHiJkL aBcDeFGhIjKl AbCdEfGhIiJKl
@@ -172,7 +173,8 @@ module When
172
173
  # 呉:: 乾象暦 223 - 280
173
174
  Chinese0223 = [PatternTableBasedLuniSolar, {
174
175
  'origin_of_MSC'=>222, 'origin_of_LSC'=>1802173,
175
- 'indices'=> _IndicesM1,
176
+ 'before' => 'Chinese_103', 'after' => 'Chinese0239',
177
+ 'indices'=> ChineseIndices,
176
178
  'rule_table'=> %w(
177
179
  AbCdEfFGhIjKl aBcDeFgHiJKl AbCdEfGhIjKl ABcDdEfGhIjKl
178
180
  AbCdEFgHiJkL aBcDeFgHiJKlL aBcDeFgHiJkL aBCdEfGhIjKl AbCdEFgHhIjKl
@@ -194,6 +196,7 @@ module When
194
196
  # 魏:: 景初暦 237 - 239 (歳首 建丑月)
195
197
  Chinese0237 = [PatternTableBasedLuniSolar, {
196
198
  'origin_of_MSC'=>236, 'origin_of_LSC'=>1807282, 'border'=>'0*12-01',
199
+ 'before' => 'Chinese_103', 'after' => 'Chinese0239',
197
200
  'indices'=> _IndicesM12,
198
201
  'rule_table'=> %w(AaBcDeFgHiJKl AbCdeFgHiJkL aBcDeFGhIjJkL aBcDeFgHiJKl)
199
202
  }
@@ -204,7 +207,8 @@ module When
204
207
  # 北魏:: 景初暦 386? - 451
205
208
  Chinese0239 = [PatternTableBasedLuniSolar, {
206
209
  'origin_of_MSC'=>239, 'origin_of_LSC'=>1808404,
207
- 'indices'=> _IndicesM1,
210
+ 'before' => 'Chinese0237', 'after' => 'Chinese0445',
211
+ 'indices'=> ChineseIndices,
208
212
  'rule_table'=> %w(
209
213
  aBcDeFgHiJKl AbCdEfGhIjKl
210
214
  AbCDeFfGhIjKl AbCdEFgHiJkL aBcDeFgHiJKl AbCcDeFgHiJkL aBCdEfGhIjKl
@@ -263,7 +267,8 @@ module When
263
267
  # 及び後梁
264
268
  Chinese0445 = [PatternTableBasedLuniSolar, {
265
269
  'origin_of_MSC'=>445, 'origin_of_LSC'=>1883618,
266
- 'indices'=> _IndicesM1,
270
+ 'before' => 'Chinese0239', 'after' => 'Chinese0523',
271
+ 'indices'=> ChineseIndices,
267
272
  'rule_table'=> %w(
268
273
  AbCdEeFgHiJkL
269
274
  AbCdEfGhIjKl AbCDeFgHiJkL aBbCdEfGHiJkL aBcDeFgHiJkL AbCdEfGhIjJkL
@@ -297,14 +302,15 @@ module When
297
302
  AbCdEfGHiJkL aBcDeFgHiJKlL aBcDeFgHiJkL aBCdEfGhIjKl AbCdEfGHiIjKl
298
303
  AbCdEfGhIJkL aBcDeFgHiJkL aBCdEeFgHiJkL aBcDeFGhIjKl AbCdEfGhIJkL
299
304
  aBbCdEfGhIjKl ABcDeFgHiJkL aBcDeFGhIjKkL aBcDeFgHIjKl AbCdEfGhIjKl
300
- ABcDeFgGhIjKl AbCdEFgHiJkL aBcDeFgHIjKl AbCdDEfGhIjKl )
305
+ ABcDeFgGhIjKl AbCdEFgHiJkL aBcDeFgHIjKl AbCcDeFgHiJkL )
301
306
  }
302
307
  ]
303
308
 
304
309
  # 後秦:: 三紀暦 384 - 417
305
310
  Chinese0384 = [PatternTableBasedLuniSolar, {
306
311
  'origin_of_MSC'=>384, 'origin_of_LSC'=>1861352,
307
- 'indices'=> _IndicesM1,
312
+ 'before' => 'Chinese0239', 'after' => 'Chinese0239',
313
+ 'indices'=> ChineseIndices,
308
314
  'rule_table'=> %w(
309
315
  AbCdEfGhIjKl AbCDeEfGhIjKl
310
316
  AbCdEfGHiJkL aBcDeFgHiJkL AaBcDeFgHiJkL aBCdEfGhIjKl AbCdEfGHiJjKl
@@ -322,7 +328,8 @@ module When
322
328
  # 北魏:: 玄始暦 452 - 522
323
329
  Chinese0412 = [PatternTableBasedLuniSolar, {
324
330
  'origin_of_MSC'=>412, 'origin_of_LSC'=>1871570,
325
- 'indices'=> _IndicesM1,
331
+ 'before' => 'Chinese0239', 'after' => 'Chinese0523',
332
+ 'indices'=> ChineseIndices,
326
333
  'rule_table'=> %w(
327
334
  aBcDeFgHhIjKL aBcDeFgHiJkL aBcDEfGhIjKl AbCdEeFgHIjKl
328
335
  AbCdEfGhIjKL aBcDeFgHiJkL aBbCDeFgHiJkL aBcDeFgHIjKl AbCdEfGhIjKKl
@@ -356,7 +363,8 @@ module When
356
363
  # 北斉:: 天保暦 551 - 577
357
364
  Chinese0540 = [PatternTableBasedLuniSolar, {
358
365
  'origin_of_MSC'=>540, 'origin_of_LSC'=>1918317,
359
- 'indices'=> _IndicesM1,
366
+ 'before' => 'Chinese0523', 'after' => 'Chinese0523',
367
+ 'indices'=> ChineseIndices,
360
368
  'rule_table'=> %w(
361
369
  aBcDeEfGhIjKl
362
370
  ABcDeFgHiJkL aBcDeFGhIjKl AaBcDeFgHIjKl AbCdEfGhIjKl ABcDeFgHiJjKl
@@ -378,7 +386,7 @@ module When
378
386
  # 北周・隋:: 大象暦 579 - 583
379
387
  # 隋:: 開皇暦 584 - 596
380
388
  # 隋・唐:: 大業暦 597 - 618
381
- # 唐:: 戊寅暦 619 - 664
389
+ # 唐:: 戊寅元暦 619 - 664
382
390
  # 唐・周:: 麟徳暦 665 - 728 総法 1340(小余の分母)
383
391
  # 唐:: 大衍暦 729 - 761 通法 3040( 〃 )
384
392
  # 唐:: 五紀暦 762 - 783 通法 1340( 〃 )
@@ -390,7 +398,8 @@ module When
390
398
  # (後晋:: 調元暦? 944 - 946)
391
399
  Chinese0523 = [PatternTableBasedLuniSolar, {
392
400
  'origin_of_MSC'=>523, 'origin_of_LSC'=>1912115,
393
- 'indices'=> _IndicesM1,
401
+ 'before' => 'Chinese0412', 'after' => 'Chinese0956',
402
+ 'indices'=> ChineseIndices,
394
403
  'rule_table'=> %w(
395
404
  AbCdEfGhIjKL aBbCdEfGhIjKl AbCDeFgHiJkL
396
405
  aBcDeFgHIjKkL aBcDeFgHiJKl AbCdEfGhIjKl AbCDeFgGhIjKl AbCdEfGHiJkL
@@ -492,10 +501,10 @@ module When
492
501
  # 唐・周:: 麟徳暦 688 - 700 (歳首 建子月)
493
502
  Chinese0689 = [PatternTableBasedLuniSolar, {
494
503
  'origin_of_MSC'=>688, 'origin_of_LSC'=>1972387, 'border'=>'0*11-01',
504
+ 'before' => 'Chinese0523', 'after' => 'Chinese0523',
495
505
  'indices'=> [
496
- Coordinates::Index.new({:branch=>{1=>When.Resource('_m:CalendarTerms::閏')},
497
- :trunk=>When.Resource('_m:ChineseTerms::MonthA::*')}),
498
- Coordinates::DefaultDayIndex
506
+ When.Index('Chinese::MonthA', {:branch=>{1=>'_m:Calendar::閏'}}),
507
+ When::Coordinates::DefaultDayIndex
499
508
  ],
500
509
  'rule_table'=> %w(
501
510
  AbcDeFgHIJkL aBcdEfGhIIJkL aBcdEfgHIjKL
@@ -508,10 +517,10 @@ module When
508
517
  # 唐:: 五紀暦 762 (歳首 建子月)
509
518
  Chinese0761 = [PatternTableBasedLuniSolar, {
510
519
  'origin_of_MSC'=>760, 'origin_of_LSC'=>1998670, 'border'=>'0*11-01',
520
+ 'before' => 'Chinese0523', 'after' => 'Chinese0523',
511
521
  'indices'=> [
512
- Coordinates::Index.new({:branch=>{1=>When.Resource('_m:CalendarTerms::閏')},
513
- :trunk=>When.Resource('_m:ChineseTerms::MonthB::*')}),
514
- Coordinates::DefaultDayIndex
522
+ When.Index('Chinese::MonthB', {:branch=>{1=>'_m:Calendar::閏'}}),
523
+ When::Coordinates::DefaultDayIndex
515
524
  ],
516
525
  'rule_table'=> %w(AbcDdeFgHIjKL aBcDefGhIJkL AbCdEfgHiJkL)
517
526
  }
@@ -521,7 +530,7 @@ module When
521
530
  # 『唐・日本における進朔に関する研究』(2013-10版)を使用する場合の朔閏表(一部修正あり)
522
531
  #
523
532
  # 隋・唐:: 大業暦 618
524
- # 唐:: 戊寅暦 619 - 664
533
+ # 唐:: 戊寅元暦 619 - 664
525
534
  # 唐・周:: 麟徳暦 665 - 728 総法 1340(小余の分母)
526
535
  # 唐:: 大衍暦 729 - 761 通法 3040( 〃 )
527
536
  # 唐:: 五紀暦 762 - 783 通法 1340( 〃 )
@@ -531,7 +540,8 @@ module When
531
540
  # 唐~後梁:: 崇玄暦 893 - 907
532
541
  Chinese0618 = [PatternTableBasedLuniSolar, {
533
542
  'origin_of_MSC'=>618, 'origin_of_LSC'=>1946814,
534
- 'indices'=> _IndicesM1,
543
+ 'before' => 'Chinese0523', 'after' => 'Chinese0523',
544
+ 'indices'=> ChineseIndices,
535
545
  'rule_table'=> %w( aBcDeFgHiJkL ABbcDefGhIJKl AbCdeFgHiJkL
536
546
  ABcDefGhIjJkL AbCDefGhIjKl AbCDeFgHiJkL aBcDeFGgHiJkL aBcdEFgHIjKl
537
547
  AbCdeFgHIJkL aBcCdeFgHIjKL aBcdEfgHIjKL AbCdeFghIJkLL AbCdeFgHiJkL
@@ -606,10 +616,10 @@ module When
606
616
  # 唐・周:: 麟徳暦 688 - 700 (歳首 建子月)
607
617
  Chinese0618B = [PatternTableBasedLuniSolar, {
608
618
  'origin_of_MSC'=>688, 'origin_of_LSC'=>1972387, 'border'=>'0*11-01',
619
+ 'before' => 'Chinese0618', 'after' => 'Chinese0618',
609
620
  'indices'=> [
610
- Coordinates::Index.new({:branch=>{1=>When.Resource('_m:CalendarTerms::閏')},
611
- :trunk=>When.Resource('_m:ChineseTerms::MonthA::*')}),
612
- Coordinates::DefaultDayIndex
621
+ When.Index('Chinese::MonthA', {:branch=>{1=>'_m:Calendar::閏'}}),
622
+ When::Coordinates::DefaultDayIndex
613
623
  ],
614
624
  'rule_table'=> %w( AbcDeFgHIJkL aBcdEfGhIIJkL aBcdEfgHIjKL
615
625
  AbCdeFghIJKL aBcDeeFghIJKL abCdEfGhIjkL AbCDeFgHiJkL aBbCdEFgHiJkL
@@ -624,10 +634,10 @@ module When
624
634
  # 唐:: 五紀暦 762 (歳首 建子月)
625
635
  Chinese0618C = [PatternTableBasedLuniSolar, {
626
636
  'origin_of_MSC'=>760, 'origin_of_LSC'=>1998670, 'border'=>'0*11-01',
637
+ 'before' => 'Chinese0618', 'after' => 'Chinese0618',
627
638
  'indices'=> [
628
- Coordinates::Index.new({:branch=>{1=>When.Resource('_m:CalendarTerms::閏')},
629
- :trunk=>When.Resource('_m:ChineseTerms::MonthB::*')}),
630
- Coordinates::DefaultDayIndex
639
+ When.Index('Chinese::MonthB', {:branch=>{1=>'_m:Calendar::閏'}}),
640
+ When::Coordinates::DefaultDayIndex
631
641
  ],
632
642
  'rule_table'=> %w(AbcDdeFgHIjKL aBcdeFGhIJkL AbCdEFghiJkL)
633
643
  }
@@ -644,7 +654,8 @@ module When
644
654
  # 南明:: 大統暦 1645 - 1662
645
655
  Chinese0939 = [PatternTableBasedLuniSolar, {
646
656
  'origin_of_MSC'=>939, 'origin_of_LSC'=>2064050,
647
- 'indices'=> _IndicesM1,
657
+ 'before' => 'Chinese0523', 'after' => 'Chinese1645',
658
+ 'indices'=> ChineseIndices,
648
659
  'rule_table'=> %w(
649
660
  ABcDefGgHiJkL ABcDefGhIjKl
650
661
  ABcDEfgHiJkL aBcCDeFgHiJkL aBcDeFGhIjKl AbCdeFGhIJkLl AbcDeFgHIJkL
@@ -834,7 +845,8 @@ module When
834
845
  # 南宋:: 本天暦 1277 - 1279
835
846
  Chinese0956 = [PatternTableBasedLuniSolar, {
836
847
  'origin_of_MSC'=>947, 'origin_of_LSC'=>2066974,
837
- 'indices'=> _IndicesM1,
848
+ 'before' => 'Chinese0523', 'after' => 'Chinese0939',
849
+ 'indices'=> ChineseIndices,
838
850
  'rule_table'=> %w(
839
851
  AbCdeFggHIjKL AbCdeFghIJkL AbCDefGhiJKl AbCDeEfGhIjKl
840
852
 
@@ -916,6 +928,7 @@ module When
916
928
  # 方臘:: 紀元暦 1118 - 1120 (歳首 建子月)
917
929
  Chinese1119 = [PatternTableBasedLuniSolar, {
918
930
  'origin_of_MSC'=>1118, 'origin_of_LSC'=>2129431, 'border'=>'0*11-01',
931
+ 'before' => 'Chinese0956', 'after' => 'Chinese0956',
919
932
  'indices'=> _IndicesM11,
920
933
  'rule_table'=> %w( aBCdEfGhIiJkL aBcDEfGhIjKl AbCdEfGHiJkL)
921
934
  }
@@ -926,9 +939,11 @@ module When
926
939
  # 清:: 時憲暦 1669 - 1725 天聡戊辰元法
927
940
  # 清:: 時憲暦 1726 - 1741 康熙甲子元法
928
941
  # 清:: 時憲暦 1742 - 1911 雍正癸卯元法
942
+ # 中華民国:: 農暦 1912 - 1930 (北京時間 +07:45:34 で計算)
929
943
  Chinese1645 = [PatternTableBasedLuniSolar, {
930
944
  'origin_of_MSC'=>1645, 'origin_of_LSC'=>2321912,
931
- 'indices'=> _IndicesM1,
945
+ 'before' => 'Chinese0939', 'after' => 'ChineseLuniSolar?time_basis=+08',
946
+ 'indices'=> ChineseIndices,
932
947
  'rule_table'=> %w(
933
948
  aBcdEffGhIJKL
934
949
  aBcdEfgHiJKL aBCdeFghIjKL aBCdDeFghIjKl ABcDEfGhiJkL aBCdEfGHijKl
@@ -990,7 +1005,11 @@ module When
990
1005
 
991
1006
  aBcdEfGhIJKl AbCdeFgHiJKL aBcDeeFghIJkL ABcDefGhiJKl ABcDEfgHiJkL
992
1007
  aBCdDeFgHiJkL aBcDeFGhIjKl AbcDEfGhIJkL aBbcDeFgHIJkL aBcdEfGhIJKl
993
- AbCdeFfgHIjKL )
1008
+ AbCdeFfgHIjKL
1009
+ AbCdeFghIJkL ABcDefGhiJkL ABcDeEfGhiJkL AbCDeFgHiJkl
1010
+ ABcDeFGhIjKl AbbCdEFgHIjKl AbcDeFgHIjKL aBcdEfgGHiJKL aBcdEfgHiJKL
1011
+ AbCdeFghIjKL AbCDeeFghIjKL aBCdEfGhiJkL aBCdEFgHiJkl AbCdDEfGHiJkL
1012
+ abCdEfGHiJKl AbcDeFgHiJKL aBbcDefGhIJKL aBcdEfgHiJKL aBCdeFfgHiJKl)
994
1013
  }
995
1014
  ]
996
1015
  end