zakuro 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +48 -13
  3. data/VERSION +1 -1
  4. data/doc/dropped_date.md +93 -0
  5. data/doc/error.md +45 -0
  6. data/doc/operation/csv/month.csv +100 -79
  7. data/doc/operation/operation.xlsx +0 -0
  8. data/lib/zakuro/calculation/base/day.rb +52 -0
  9. data/lib/zakuro/calculation/base/gengou.rb +5 -5
  10. data/lib/zakuro/calculation/base/linear_gengou.rb +5 -5
  11. data/lib/zakuro/calculation/base/operated_year.rb +26 -24
  12. data/lib/zakuro/calculation/base/year.rb +7 -7
  13. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +55 -47
  14. data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +28 -24
  15. data/lib/zakuro/calculation/cycle/zodiac.rb +22 -20
  16. data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +38 -29
  17. data/lib/zakuro/calculation/era/gengou/internal/connector.rb +4 -4
  18. data/lib/zakuro/calculation/era/gengou/internal/counter.rb +16 -16
  19. data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +74 -72
  20. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +16 -16
  21. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +58 -35
  22. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +3 -3
  23. data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +111 -113
  24. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +6 -6
  25. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +7 -9
  26. data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +22 -20
  27. data/lib/zakuro/calculation/era/version/internal/crawler.rb +39 -22
  28. data/lib/zakuro/calculation/era/version/version.rb +12 -10
  29. data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +13 -9
  30. data/lib/zakuro/calculation/monthly/const.rb +18 -0
  31. data/lib/zakuro/calculation/monthly/initialized_month.rb +40 -38
  32. data/lib/zakuro/calculation/monthly/month.rb +17 -17
  33. data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
  34. data/lib/zakuro/calculation/monthly/operated_month.rb +37 -86
  35. data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
  36. data/lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb +44 -0
  37. data/lib/zakuro/calculation/option/dropped_date/location.rb +135 -0
  38. data/lib/zakuro/calculation/range/abstract_full_range.rb +40 -25
  39. data/lib/zakuro/calculation/range/abstract_operation_range.rb +111 -109
  40. data/lib/zakuro/calculation/range/dated_full_range.rb +1 -1
  41. data/lib/zakuro/calculation/range/dated_operation_range.rb +1 -1
  42. data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
  43. data/lib/zakuro/calculation/range/named_full_range.rb +1 -1
  44. data/lib/zakuro/calculation/range/named_operation_range.rb +1 -1
  45. data/lib/zakuro/calculation/range/operated_solar_term.rb +220 -0
  46. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +32 -29
  47. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +115 -117
  48. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +1 -1
  49. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +48 -46
  50. data/lib/zakuro/calculation/stella/solar/abstract_average.rb +31 -26
  51. data/lib/zakuro/calculation/stella/solar/abstract_location.rb +7 -5
  52. data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
  53. data/lib/zakuro/calculation/summary/internal/day.rb +42 -0
  54. data/lib/zakuro/calculation/summary/internal/month.rb +32 -11
  55. data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
  56. data/lib/zakuro/calculation/summary/internal/option.rb +101 -0
  57. data/lib/zakuro/calculation/summary/japan/range.rb +145 -118
  58. data/lib/zakuro/calculation/summary/japan/single.rb +87 -87
  59. data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +57 -50
  60. data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
  61. data/lib/zakuro/calculation/summary/western/range.rb +95 -92
  62. data/lib/zakuro/calculation/summary/western/single.rb +78 -76
  63. data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +123 -119
  64. data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +63 -56
  65. data/lib/zakuro/calculation/type/old_float.rb +2 -2
  66. data/lib/zakuro/calculation/type/optional.rb +46 -0
  67. data/lib/zakuro/condition.rb +142 -92
  68. data/lib/zakuro/context/context.rb +44 -0
  69. data/lib/zakuro/context/option.rb +119 -0
  70. data/lib/zakuro/context/version_class_resolver.rb +112 -0
  71. data/lib/zakuro/era/japan/calendar.rb +35 -33
  72. data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +8 -4
  73. data/lib/zakuro/era/japan/gengou/alignment/division.rb +117 -118
  74. data/lib/zakuro/era/japan/gengou/alignment/line.rb +7 -5
  75. data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +20 -14
  76. data/lib/zakuro/era/japan/gengou/alignment.rb +27 -25
  77. data/lib/zakuro/era/japan/gengou/resource/parser.rb +51 -34
  78. data/lib/zakuro/era/japan/gengou/resource/type.rb +45 -37
  79. data/lib/zakuro/era/japan/gengou/resource/validator.rb +34 -32
  80. data/lib/zakuro/era/japan/gengou.rb +28 -26
  81. data/lib/zakuro/era/japan/version.rb +18 -16
  82. data/lib/zakuro/era/western/calendar.rb +104 -88
  83. data/lib/zakuro/exception/case/pattern.rb +39 -3
  84. data/lib/zakuro/exception/case/preset.rb +2 -2
  85. data/lib/zakuro/exception/exception.rb +17 -15
  86. data/lib/zakuro/exception/zakuro_error.rb +19 -1
  87. data/lib/zakuro/gateway/locale/date.rb +2 -2
  88. data/lib/zakuro/gateway/locale/range.rb +3 -3
  89. data/lib/zakuro/gateway/range.rb +3 -3
  90. data/lib/zakuro/gateway/single.rb +14 -3
  91. data/lib/zakuro/merchant.rb +79 -9
  92. data/lib/zakuro/operation/month/parser.rb +252 -249
  93. data/lib/zakuro/operation/month/type.rb +17 -8
  94. data/lib/zakuro/operation/month/validator.rb +148 -144
  95. data/lib/zakuro/operation/operation.rb +38 -36
  96. data/lib/zakuro/operation/yaml/month.yaml +955 -281
  97. data/lib/zakuro/output/response.rb +107 -141
  98. data/lib/zakuro/result/data/option/abstract_option.rb +37 -0
  99. data/lib/zakuro/result/data/option/dropped_date/calculation.rb +47 -0
  100. data/lib/zakuro/result/data/option/dropped_date/option.rb +47 -0
  101. data/lib/zakuro/result/data/option/dropped_date/solar_term.rb +48 -0
  102. data/lib/zakuro/result/data/single_day.rb +9 -1
  103. data/lib/zakuro/result/operation/month/annotation.rb +2 -2
  104. data/lib/zakuro/result/operation/month/history.rb +2 -2
  105. data/lib/zakuro/result/operation/month.rb +31 -0
  106. data/lib/zakuro/result/operation.rb +39 -0
  107. data/lib/zakuro/result/result.rb +3 -3
  108. data/lib/zakuro/tools/stringifier.rb +67 -42
  109. data/lib/zakuro/tools/typeconv.rb +17 -15
  110. data/lib/zakuro/tools/typeof.rb +15 -13
  111. data/lib/zakuro/version/daien/cycle/remainder.rb +2 -2
  112. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
  113. data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +31 -0
  114. data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
  115. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -37
  116. data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
  117. data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -47
  118. data/lib/zakuro/version/daien/stella/origin/average_november.rb +15 -13
  119. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +23 -21
  120. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +22 -20
  121. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +12 -10
  122. data/lib/zakuro/version/daien/stella/solar/average.rb +53 -51
  123. data/lib/zakuro/version/daien/stella/solar/interval.rb +19 -17
  124. data/lib/zakuro/version/daien/stella/solar/value.rb +13 -11
  125. data/lib/zakuro/version/genka/cycle/remainder.rb +4 -4
  126. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
  127. data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +31 -0
  128. data/lib/zakuro/version/genka/range/annual_range.rb +48 -44
  129. data/lib/zakuro/version/genka/stella/origin/first_term.rb +30 -28
  130. data/lib/zakuro/version/genka/stella/origin/january.rb +22 -20
  131. data/lib/zakuro/version/gihou/cycle/remainder.rb +2 -2
  132. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +9 -9
  133. data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +31 -0
  134. data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
  135. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -37
  136. data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
  137. data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -47
  138. data/lib/zakuro/version/gihou/stella/origin/average_november.rb +15 -13
  139. data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +23 -21
  140. data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +24 -22
  141. data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +12 -10
  142. data/lib/zakuro/version/gihou/stella/solar/average.rb +52 -50
  143. data/lib/zakuro/version/gihou/stella/solar/interval.rb +19 -17
  144. data/lib/zakuro/version/gihou/stella/solar/value.rb +13 -11
  145. data/lib/zakuro/version/senmyou/const/remainder.rb +7 -1
  146. data/lib/zakuro/version/senmyou/cycle/remainder.rb +37 -2
  147. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +10 -10
  148. data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +33 -0
  149. data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
  150. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -36
  151. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
  152. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -34
  153. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +15 -13
  154. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +23 -21
  155. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +22 -20
  156. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +12 -10
  157. data/lib/zakuro/version/senmyou/stella/solar/average.rb +52 -50
  158. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +19 -17
  159. data/lib/zakuro/version/senmyou/stella/solar/value.rb +13 -11
  160. metadata +27 -7
  161. data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -218
  162. data/lib/zakuro/result/operation/month/bundle.rb +0 -36
  163. data/lib/zakuro/result/operation/operation.rb +0 -44
  164. data/lib/zakuro/version/context.rb +0 -44
  165. data/lib/zakuro/version/version_class_resolver.rb +0 -74
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 294b07e6f6f82cad6ed7d5332d96a0c147ee1cbcbb842faa745918f1d8fbac2e
4
- data.tar.gz: 41341f57aab606cea9a86c75aa4dbef8a8d247421d7428ddf5f1e442afc1b8db
3
+ metadata.gz: 55eefe338c00e84a3abd4377d3ddbe8663433cb65077bbe169d4cc4b53a9fe74
4
+ data.tar.gz: 562c38986fe3dcf2723d7491762a9dc4e23149e6899b5e0b1a4fb78f10ddfa89
5
5
  SHA512:
6
- metadata.gz: 9f3aee8d972a13e41ae98cb6b600f2032e833380a845513b2a738bf045e7d36a719a2e31161fd90f23194bdee4e0a690dc931934ad30ab0940742f20ea0f7bc7
7
- data.tar.gz: 8c8ea9c23b11c28910cbfcdad25dec4720f919a1bbb0551737f8cf82cc62cd59621dcdd4770580d81c7a4a1c8d8859765e3ae7cd39592369a25dd89e1da9932d
6
+ metadata.gz: 70eefaeed22b8748ff010bf64b1ef95ac3bac08bc6af2a7cbd0183b13b79ef5af62bb51b5c49197403eda02734d98cf3af71528f59d04c8ba1137f4fdbe2a92e
7
+ data.tar.gz: 34005b1a9c792df1251a040f0cf9f012b92256fe5609d95f65e627b405d7c767fbda949fab046a93884819a38907ff7e64bf58cb77b8150a055084721bd67452
data/README.md CHANGED
@@ -12,6 +12,14 @@ zakuro は日本の暦を扱う暦算ライブラリです。
12
12
 
13
13
  ## 導入
14
14
 
15
+ ### Ruby
16
+
17
+ 次の範囲で動作確認しております。
18
+
19
+ `2.6.x - 3.0.x`
20
+
21
+ ### Gem
22
+
15
23
  [rubygem](https://rubygems.org/gems/zakuro) に登録しております。
16
24
 
17
25
  ```ruby
@@ -63,8 +71,7 @@ western_date = Date.new(862, 2, 3)
63
71
  # 初期化時の設定
64
72
  merchant = Zakuro::Merchant.new(condition: { date: western_date })
65
73
  puts merchant.commit.to_json
66
- # => {"data":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"
67
- 大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"}}}}
74
+ # => {"data":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"options":{}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"options":{}}}}
68
75
 
69
76
  western_date = Date.new(1685, 2, 3)
70
77
 
@@ -72,12 +79,12 @@ western_date = Date.new(1685, 2, 3)
72
79
  # merchant = Zakuro::Merchant.new
73
80
  merchant.offer(condition: { date: western_date })
74
81
  puts merchant.commit.to_json
75
- # => {"data":{"year":{"first_gengou":{"name":"貞享","number":1},"second_gengou":{"name":"","number":-1},"zodiac_name":"甲子","total_days":354},"month":{"number":12,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"壬辰","remainder":"28-4182","western_date":"1685-01-05"},"odd_solar_terms":[{"index":1,"remainder":"30-890"}],"even_solar_terms":[{"index":2,"remainder":"45-2726"}]},"day":{"number":30,"zodiac_name":"辛酉","remainder":"57-4182","western_date":"1685-02-03"}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞享","number":1},"second_gengou":{"name":"","number":-1},"zodiac_name":"甲子","total_days":354},"month":{"number":12,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"壬辰","remainder":"28-4182","western_date":"1685-01-05"},"odd_solar_terms":[{"index":1,"remainder":"30-890"}],"even_solar_terms":[{"index":2,"remainder":"45-2726"}]},"day":{"number":30,"zodiac_name":"辛酉","remainder":"57-4182","western_date":"1685-02-03"}}}}
82
+ # => {"data":{"year":{"first_gengou":{"name":"貞享","number":1},"second_gengou":{"name":"","number":-1},"zodiac_name":"","total_days":354},"month":{"number":12,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"壬辰","remainder":"28-4182","western_date":"1685-01-05"},"odd_solar_terms":[{"index":1,"remainder":"30-890"}],"even_solar_terms":[{"index":2,"remainder":"45-2726"}]},"day":{"number":30,"zodiac_name":"辛酉","remainder":"57-4182","western_date":"1685-02-03"},"options":{}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞享","number":1},"second_gengou":{"name":"","number":-1},"zodiac_name":"","total_days":354},"month":{"number":12,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"壬辰","remainder":"28-4182","western_date":"1685-01-05"},"odd_solar_terms":[{"index":1,"remainder":"30-890"}],"even_solar_terms":[{"index":2,"remainder":"45-2726"}]},"day":{"number":30,"zodiac_name":"辛酉","remainder":"57-4182","western_date":"1685-02-03"},"options":{}}}}
76
83
 
77
84
  # 期間検索
78
85
  merchant = Zakuro::Merchant.new(condition: { range: {start: Date.new(862, 2, 3), last: Date.new(862, 2, 4)}})
79
86
  puts merchant.commit.to_json
80
- {"list":[{"data":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"}}}},{"data":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":2,"zodiac_name":"辛未","remainder":"7-1282","western_date":"0862-02-04"}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":2,"zodiac_name":"辛未","remainder":"7-1282","western_date":"0862-02-04"}}}}]}
87
+ # => {"list":[{"data":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"options":{}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"options":{}}}},{"data":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":2,"zodiac_name":"辛未","remainder":"7-1282","western_date":"0862-02-04"},"options":{}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":2,"zodiac_name":"辛未","remainder":"7-1282","western_date":"0862-02-04"},"options":{}}}}]}
81
88
  ```
82
89
 
83
90
  # 条件
@@ -93,7 +100,7 @@ puts merchant.commit.to_json
93
100
  | 範囲(終了日) | | last | Date | 西暦日 |
94
101
  | | | | String | 和暦日/西暦日 |
95
102
  | 列 | columns | | Array | 取得したい列の列名 |
96
- | オプション | options | | Array | 取得オプション |
103
+ | オプション | options | | Hash<String, Object> | 取得オプション |
97
104
 
98
105
  現時点では `date` と `range` のみ対応中です。
99
106
 
@@ -101,14 +108,22 @@ puts merchant.commit.to_json
101
108
 
102
109
  | 項目名 | キー名 | データ型 | データ | 備考 |
103
110
  |--------|-----------|----------|--------|------------------------|
104
- | 単位 | unit | String | year | 年単位 |
105
- | | | | month | 月単位 |
106
- | | | | day | 日単位(デフォルト) |
107
- | 没日 | lost_days | TRUE | | 没日あり |
108
- | | | FALSE | | 没日なし(デフォルト) |
111
+ | | version | String | Genka | 元嘉暦 |
112
+ | | | | Gihou | 儀鳳暦 |
113
+ | | | | Daien | 大衍暦 |
114
+ | | | | Senmyou | 宣明暦 |
115
+ | | | | Joukyou | 貞享暦 |
116
+ | | | | Kansei | 寛政暦 |
117
+ | | | | Tenpou | 天保暦 |
118
+ | | | | Gregorio | グレゴリオ暦 |
119
+ | | | | | 指定なし(デフォルト) |
120
+ | 没日 | dropped_days | TRUE | | 没日あり |
121
+ | | | FALSE | | 没日なし(デフォルト) |
109
122
  | 四季 | seasons | TRUE | | 四季あり |
110
123
  | | | FALSE | | 四季なし(デフォルト) |
111
124
 
125
+ 現時点では宣明暦の [没日](./doc/dropped_date.md) のみ試験的に対応しております(結果未検証)。
126
+
112
127
  # 期待値
113
128
  暦算値は『日本暦日原典』、元号の切り替えは『日本史年表 第5版』を範とします。
114
129
 
@@ -126,7 +141,7 @@ puts merchant.commit.to_json
126
141
  | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考   |
127
142
  |----------|-----------|---|---|-----------------------------------|--------|---------------------------------------|
128
143
  | 日付情報 | data | | | Zakuro::Result::Data::SingleDay | - | 運用値(計算値は運用情報内を参照のこと)|
129
- | 運用情報 | operation | | | Zakuro::Result::Operation::Bundle | - | - |
144
+ | 運用情報 | operation | | | Zakuro::Result::Operation | - | - |
130
145
 
131
146
  ### Zakuro::Result::Range
132
147
 
@@ -166,16 +181,17 @@ puts merchant.commit.to_json
166
181
  | 日の干支 | | zodiac_name | | String | 乙卯 | 日の干支 |
167
182
  | 日の大余小余 | | remainder | | String | 51-2479 | 大余小余 |
168
183
  | 西暦日 | | western_date | | String | 0937-02-14 | 西暦日 |
184
+ | オプション | options | | | Hash<String, Zakuro::Result::Data::Option::AbstractOption>| | オプション値 |
169
185
 
170
186
  ### Zakuro::Result::Operation
171
187
 
172
188
  | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
173
189
  |--------------|----------|------------|-------------|--------------------------------------------|---------|----------------------|
174
190
  | 運用有無 | operated |   |   | True/False | true |   |
175
- | 月別履歴情報 | month |   |   | Zakuro::Result::Operation::Month::Bundle |   |   |
191
+ | 月別履歴情報 | month |   |   | Zakuro::Result::Operation::Month |   |   |
176
192
  | 計算値 | original |   |   | Zakuro::Result::Data::SingleDay |   | 運用値差替前の計算値 |
177
193
 
178
- ### Zakuro::Result::Operation::Month::Bundle
194
+ ### Zakuro::Result::Operation::Month
179
195
 
180
196
  | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
181
197
  |--------------------------|----------|------------|----------|--------------------------------------------|--------------|---------------------------------------------|
@@ -195,6 +211,20 @@ puts merchant.commit.to_json
195
211
  | 注釈内容 |   | | description | String | 計算は51乙卯であるが, 日本紀略に甲寅朔とある。<br>正月甲寅朔のユリウス暦日は2月13日となる。(元旦日食 をさけるための変更か) |   |
196
212
  | 注釈補記 |   | | note | String | - | 原文訂正 |
197
213
 
214
+ ### Zakuro::Result::Data::Option::AbstractOption
215
+
216
+ #### Zakuro::Result::Data::Option::DroppedDate::Option
217
+
218
+ キー: dropped_date
219
+
220
+ | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
221
+ | -------------------- | ----------- | ---------- | --------- | ------------------------------------------------------ | -------- | ------------------ |
222
+ | オプション値有無 | matched | | | True/False | true | |
223
+ | 演算値 | calculation | | | Zakuro::Result::Data::Option::DroppedDate::Calculation | | |
224
+ | 没余 | | remainder | | String | 59-34155 | |
225
+ | 二十四節気 | | solar_term | | Zakuro::Result::Data::Option::DroppedDate::SolarTerm | | |
226
+ | 二十四節気番号 | | | index | Integer | 6 | |
227
+ | 二十四節気の大余小余 | | | remainder | String | 49-7203 | |
198
228
 
199
229
  # 元号
200
230
 
@@ -209,6 +239,11 @@ puts merchant.commit.to_json
209
239
 
210
240
  [宣明暦](./lib/zakuro/version/senmyou/README.md) のみ記載しております。
211
241
 
242
+ # 例外
243
+
244
+ 条件不正などで例外が発生します。
245
+ 詳細は [例外処理](./doc/error.md) を参照してください。
246
+
212
247
  ## コントリビュート(Contributing)
213
248
 
214
249
  バグ報告/修正はこちらまで。
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.9.0
@@ -0,0 +1,93 @@
1
+ # 没日
2
+ 没日を端的に説明すると、1太陽年(365.24..日)を360日で表わすために、一定の法則で `存在しない日` として配置された日である
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
+ * 常気の小余 >= 6564.3
29
+
30
+ ```
31
+ 三百六十ヲ以テ之乗シ別ニ秒ヲ置テ四十五ヲ以テ之乗シ小餘ノ之上ニ加フ
32
+ 常氣ノ小余ノ數ニカクルナリ今立春ノ小余八千二百三十六秒七アリ
33
+ 故に没日ヲ求メントテマツ其立春ノ小余八千二百三十六ニ三百六十ヲカクレハ二百九十六萬四千九百六十トナル
34
+ 又別ニ秒七ヲ置テ是ニ四十五ヲカクレハ三百一十五トナル
35
+ 此ヲ右ノ二百九十六萬四千九百六十ニ加フレハ合セテ二百九十六萬五千二百七十五トナル
36
+ 又秒七ヲ八ニワリテ小余ノ次ニ置テ八千二百三十六八分七厘五毛トツテ子テ是ニ三百六十ヲカクレハ二百九十六萬五千二百七十五トナルモ同シ等法ナリ
37
+ ```
38
+
39
+ ある立春の小余: 8236.7
40
+ * A
41
+ * 8236 * 360 = 2964960
42
+ * 7 * 45 = 315
43
+ * 2964960 + 315 = 2965275
44
+ * B
45
+ * 8236 + 7/8 = 8236.875 * 360 = 2965275
46
+
47
+ ```
48
+ 而ソ章歳ノ三百零六萬八千零五十五ヲ以テ直減シ
49
+ 以ハ用ナリ置テト云心ナルヘシ此章歳ノ數三百零六萬八千零五十五ヲ置テコノ内ヲ右ノ二百九十六萬五千二百七十五去テ残テ一十萬零二千七百八十トナルナリ
50
+ 細注ニ或ハ少ヲ以テ多ニ減ストアレトモ是ハアヤマリナルヘシ
51
+ タトヘハ常氣ノ小余八千三百九十九秒七アルトキニ右ノ法ノ如クニシテミレハ三百零二萬三千九百五十五トナル
52
+ コレ章歳ノ數ニ四萬四千一百タラサルナリ
53
+ 然レハ必ラス定テ章歳ノ數ノ内ヲ減スルノ明トシ常氣ノ小余八千三百九十九秒七ヨリ多キクハナキケリ
54
+ ```
55
+ 章歳: 3068055
56
+
57
+ * 3068055 - 2965275 = 102780
58
+ * 負数はない。負数であれば正数にする
59
+
60
+ ```
61
+ 残分ヲ置テ通餘ノ四萬四千一零五十五ヲ以テ之ヲ除シ商ヲ以テ日ト為 常氣ノ之大餘ヲ加フ甲子自之ヲ命シ等外ヲ用フ也
62
+ 残分ト云ハ右ノ章歳ヲ減シタル残リ一十萬零二千七百八十トナリ此數ヲ置テ通余ノ四萬四千一零五十五ニテワレハ商ニ不盡一萬四千六百七十アリ
63
+ サテ此商二ニ常氣立春ノ大余五十六ヲ加レハ五十八トナル
64
+ コレヲ没日ノ大余ノ數トス
65
+ サテ右ノ不盡一萬四千六百七十ヲ没日ノ小余トス
66
+ 其大余ノ數モシ六十ニ満ツルトキハハラヒ去リテ其残リヲ用テサテ前ノ二十四氣ニテ攴干ヲ付タル如ク紀法ノ圖ニテ付ヘシ今大余五十八ハ壬戌ニアタルナリ
67
+ 立春一氣ノ内ニ壬戌ノ日アルヲ没日ノ日トス
68
+ サテ是ハ立春ノ一氣ヲ記セリ
69
+ 二十四氣ノ内イツレニテモ有没日ノ数小余六千五百六十四秒巳上アラハ右ノ如クニシテ求ムヘシ
70
+ ```
71
+
72
+ 通余: 44055
73
+
74
+ * 102780 / 44055 = 2.3329... ≒ 2
75
+ * 102780 % 44055 = 14670
76
+ * 56(立春大余) + 2 = 58
77
+
78
+ 没日: 58-14670
79
+
80
+ ```
81
+ 次ヲ求ルノ術
82
+ ```
83
+
84
+ ```
85
+ 大餘ニ九 小餘ニ二萬八千二百六十
86
+ 二十四氣ノ内ヲ考ヘテイツレニテモ有没日ノ小余六千五百六十四秒三以上アル時ハ右ノ法ノ如ニシテ求ムヘシ
87
+ 又一術アリモトメ得タル没日ノ大余ニ九加エ小余ニ二萬八千二百六十加エテ小余通余ノ四萬四千零五十五ニ満レハ一ニツツメテ其一ヲ大余ニ加ヘ大余六十ニ満レハ去此ノ如ク累加スレハ次々ノ没日ヲ求メ得ルナリ
88
+ 其アル日ハ有没日ノ六千五百六十四秒三以上アル處ノ氣ノ内ニアルトシルヘシ
89
+
90
+ ```
91
+ * 大余 + 9
92
+ * 小余 + 28260
93
+ * 小余 > 44055 の場合は繰り上げ
data/doc/error.md ADDED
@@ -0,0 +1,45 @@
1
+ # 例外処理
2
+
3
+ ## Zakuro::Exception::ZakuroError
4
+
5
+ 例外は `ZakuroError` に集約されます。
6
+
7
+ ```
8
+ merchant = Zakuro::Merchant.new(condition: {})
9
+ merchant.commit
10
+ Traceback (most recent call last):
11
+ 4: from ./bin/console:14:in `<main>'
12
+ 3: from (irb):5
13
+ 2: from /Users/ty/ruby/zakuro/lib/zakuro/merchant.rb:81:in `commit'
14
+ 1: from /Users/ty/ruby/zakuro/lib/zakuro/merchant.rb:132:in `make_uncommitable_error'
15
+ Zakuro::Exception::ZakuroError (an error has occurred:[{"code":"ERROR_0203","message":"検索不可能な日付指定です。"}])
16
+ ```
17
+
18
+ 例外に対応したコードとメッセージを取得できます。
19
+ ```
20
+ merchant = Zakuro::Merchant.new(condition: {})
21
+ begin
22
+ merchant.commit
23
+ rescue Zakuro::Exception::ZakuroError => e
24
+ p e.causes[0].code
25
+ p e.causes[0].message
26
+ end
27
+ => "ERROR_0203"
28
+ => "検索不可能な日付指定です。"
29
+ ```
30
+
31
+ ## エラー種別
32
+
33
+ `Zakuro::Exception::Case::Pattern` の通りです。
34
+
35
+ |コード|メッセージ|引数長|
36
+ |:----|:----|:----|
37
+ |ERROR_0001|内部エラーです。|0|
38
+ |ERROR_0101|日付の型は文字列/日付です。指定型:%s|1|
39
+ |ERROR_0102|範囲の型はhashです。指定型:%s|1|
40
+ |ERROR_0103|オプションの型はhashです。指定型:%s|1|
41
+ |ERROR_0104|列の型は配列です。指定型:%s|1|
42
+ |ERROR_0105|条件の型は配列です。指定型:%s|1|
43
+ |ERROR_0201|一日検索の日付指定が誤っています。|0|
44
+ |ERROR_0202|範囲検索の日付指定が誤っています。|0|
45
+ |ERROR_0203|検索不可能な日付指定です。|0|