zakuro 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +30 -160
  3. data/VERSION +1 -1
  4. data/doc/condition.md +36 -0
  5. data/doc/dropped_date.md +41 -0
  6. data/doc/expection.md +108 -0
  7. data/doc/usage.md +120 -0
  8. data/doc/vanished_date.md +86 -0
  9. data/doc/version/daien.md +163 -0
  10. data/doc/version/genka.md +116 -0
  11. data/doc/version/gihou.md +172 -0
  12. data/doc/version/section/common_post_process.md +60 -0
  13. data/doc/version/section/common_pre_process.md +185 -0
  14. data/doc/version/section/const.md +45 -0
  15. data/doc/version/section/decimal.md +101 -0
  16. data/doc/version/section/lunisolar_calendar.md +55 -0
  17. data/doc/version/section/senmyou_november_1st.md +41 -0
  18. data/{lib/zakuro/version/senmyou/README.md → doc/version/senmyou.md} +15 -168
  19. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +58 -0
  20. data/lib/zakuro/calculation/monthly/first_day.rb +9 -1
  21. data/lib/zakuro/calculation/option/vanished_date/abstract_parameter.rb +40 -0
  22. data/lib/zakuro/calculation/option/vanished_date/location.rb +84 -0
  23. data/lib/zakuro/calculation/range/medieval_annual_range.rb +5 -3
  24. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +1 -0
  25. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +6 -2
  26. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +14 -0
  27. data/lib/zakuro/calculation/summary/internal/option.rb +59 -4
  28. data/lib/zakuro/context/option.rb +17 -0
  29. data/lib/zakuro/context/version_class_resolver.rb +17 -1
  30. data/lib/zakuro/result/data/option/vanished_date/calculation.rb +45 -0
  31. data/lib/zakuro/result/data/option/vanished_date/option.rb +47 -0
  32. data/lib/zakuro/result/data/single_day.rb +2 -0
  33. data/lib/zakuro/version/daien/const/number.rb +2 -0
  34. data/lib/zakuro/version/daien/const/remainder.rb +7 -2
  35. data/lib/zakuro/version/daien/cycle/remainder.rb +38 -20
  36. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +2 -4
  37. data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +5 -3
  38. data/lib/zakuro/version/daien/option/vanished_date/parameter.rb +33 -0
  39. data/lib/zakuro/version/daien/stella/lunar/location.rb +5 -8
  40. data/lib/zakuro/version/genka/cycle/remainder.rb +6 -2
  41. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +14 -3
  42. data/lib/zakuro/version/genka/option/vanished_date/parameter.rb +31 -0
  43. data/lib/zakuro/version/gihou/const/remainder.rb +1 -5
  44. data/lib/zakuro/version/gihou/cycle/remainder.rb +0 -26
  45. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +2 -4
  46. data/lib/zakuro/version/gihou/option/vanished_date/parameter.rb +31 -0
  47. data/lib/zakuro/version/gihou/stella/lunar/location.rb +5 -8
  48. data/lib/zakuro/version/senmyou/const/number.rb +3 -1
  49. data/lib/zakuro/version/senmyou/const/remainder.rb +4 -2
  50. data/lib/zakuro/version/senmyou/cycle/remainder.rb +17 -34
  51. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +5 -5
  52. data/lib/zakuro/version/senmyou/option/vanished_date/parameter.rb +33 -0
  53. data/lib/zakuro/version/senmyou/stella/lunar/location.rb +6 -8
  54. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +9 -0
  55. metadata +24 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55eefe338c00e84a3abd4377d3ddbe8663433cb65077bbe169d4cc4b53a9fe74
4
- data.tar.gz: 562c38986fe3dcf2723d7491762a9dc4e23149e6899b5e0b1a4fb78f10ddfa89
3
+ metadata.gz: 64217957bc4e6be2fa7fe5e0414a3cfc4d64a424bd0a3f8d407ad911f1a4418f
4
+ data.tar.gz: 5042fd68cdb7cd76cf5b62de725db105912f14b29cc4849cdaaa1cff3110424a
5
5
  SHA512:
6
- metadata.gz: 70eefaeed22b8748ff010bf64b1ef95ac3bac08bc6af2a7cbd0183b13b79ef5af62bb51b5c49197403eda02734d98cf3af71528f59d04c8ba1137f4fdbe2a92e
7
- data.tar.gz: 34005b1a9c792df1251a040f0cf9f012b92256fe5609d95f65e627b405d7c767fbda949fab046a93884819a38907ff7e64bf58cb77b8150a055084721bd67452
6
+ metadata.gz: e4d7637971c69f269591897e645df48077eeb4504cb1c7766c0414ae3c82f190a832051dfd139589a2c04c4ba1541bbb4e89d20a755bb0a0b513c23e1f4ae633
7
+ data.tar.gz: 198cd920eb173788dc1f02e511a40f84a86d2aea10e509e2fe16bb4872244d405201ac4794e10f09232e84b01f7354208b3400304506f7efb3d6df9b184fadea
data/README.md CHANGED
@@ -58,173 +58,21 @@ Or install it yourself as:
58
58
  |1844/02/18|天保暦| |-|
59
59
  |1872/12/09|グレゴリオ暦| |-|
60
60
 
61
- # 使用方法
62
-
63
- ```
64
- require 'zakuro'
65
-
66
- # 西暦日 -> 和暦日への変換方法を示す
61
+ 表中A-Cは月の運動の計算手順ごとに分類されます。
67
62
 
68
- # ざくろ商人(Zakuro::Merchant)に西暦日を渡し、和暦日を受け取る
69
- western_date = Date.new(862, 2, 3)
63
+ 現在は「長慶宣明暦算法」の計算手順Aのみ対応しております。
70
64
 
71
- # 初期化時の設定
72
- merchant = Zakuro::Merchant.new(condition: { date: western_date })
73
- puts merchant.commit.to_json
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":{}}}}
75
-
76
- western_date = Date.new(1685, 2, 3)
77
-
78
- # 再設定
79
- # merchant = Zakuro::Merchant.new
80
- merchant.offer(condition: { date: western_date })
81
- puts merchant.commit.to_json
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":{}}}}
65
+ # 使用方法
83
66
 
84
- # 期間検索
85
- merchant = Zakuro::Merchant.new(condition: { range: {start: Date.new(862, 2, 3), last: Date.new(862, 2, 4)}})
86
- puts merchant.commit.to_json
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":{}}}}]}
88
- ```
67
+ [使用方法](./doc/usage.md) を参照してください。
89
68
 
90
69
  # 条件
91
70
 
92
- 条件(condition)のバリエーションを示します。
93
-
94
- | 項目名 | キー名 | hash内キー名 | データ型 | 備考 |
95
- |----------------|---------|--------------|----------|--------------------|
96
- | 基準日 | date | | Date | 西暦日 |
97
- | | | | String | 和暦日/西暦日 |
98
- | 範囲(開始日) | range | start | Date | 西暦日 |
99
- | | | | String | 和暦日/西暦日 |
100
- | 範囲(終了日) | | last | Date | 西暦日 |
101
- | | | | String | 和暦日/西暦日 |
102
- | 列 | columns | | Array | 取得したい列の列名 |
103
- | オプション | options | | Hash<String, Object> | 取得オプション |
104
-
105
- 現時点では `date` と `range` のみ対応中です。
106
-
107
- ## オプション
108
-
109
- | 項目名 | キー名 | データ型 | データ | 備考 |
110
- |--------|-----------|----------|--------|------------------------|
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 | | 没日なし(デフォルト) |
122
- | 四季 | seasons | TRUE | | 四季あり |
123
- | | | FALSE | | 四季なし(デフォルト) |
124
-
125
- 現時点では宣明暦の [没日](./doc/dropped_date.md) のみ試験的に対応しております(結果未検証)。
71
+ [条件](./doc/condition.md) を参照してください。
126
72
 
127
73
  # 期待値
128
- 暦算値は『日本暦日原典』、元号の切り替えは『日本史年表 第5版』を範とします。
129
-
130
- ## 種類
131
-
132
- 現状は一日検索のみ対応しております。
133
-
134
- | 項目名 | データ型 |
135
- |----------|------------------------|
136
- | 一日検索 | Zakuro::Result::Single |
137
- | 範囲検索 | Zakuro::Result::Range |
138
-
139
- ### Zakuro::Result::Single
140
-
141
- | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考   |
142
- |----------|-----------|---|---|-----------------------------------|--------|---------------------------------------|
143
- | 日付情報 | data | | | Zakuro::Result::Data::SingleDay | - | 運用値(計算値は運用情報内を参照のこと)|
144
- | 運用情報 | operation | | | Zakuro::Result::Operation | - | - |
145
-
146
- ### Zakuro::Result::Range
147
-
148
- | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考   |
149
- |----------|-----------|---|---|---------------------------------------|--------|---------------------------------------|
150
- | 日リスト | list | | | Array\<Zakuro::Result::Data::Single\> | - | 範囲内の日付情報すべて |
151
-
152
- ### Zakuro::Result::SingleDay
153
-
154
- | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
155
- |--------------------------|--------|------------------|--------------|---------------------------------|------------|----------------------------|
156
- | 年情報 | year | | | Zakuro::Result::Data::Year | | |
157
- | 年号 | | first_gengou | | Zakuro::Result::Data::Gengou | | |
158
- | 元号 | | | name | String | 承平 | |
159
- | 元号年 | | | number | Integer | 7 | |
160
- | 年号(南北朝時代の北朝) | | second_gengou | | Zakuro::Result::Data::Gengou | | |
161
- | 元号 | | | name | String | - | 南北朝時代の北朝のみ |
162
- | 元号年 | | | number | Integer | - | 南北朝時代の北朝のみ |
163
- | 年の干支 | | zodiac_name | | String | 丁酉 | |
164
- | 年の日数 | | total_days | | Integer | 354 | |
165
- | 月 | month | | | Zakuro::Result::Data::Month | | |
166
- | 月番号 | | number | | Integer | 1 | x月 |
167
- | 閏月判定 | | leaped | | True/False | false | 閏月(true)/平月(false) |
168
- | 月の大小 | | days_name | | String | 大 | 大(30日) / 小(29日) |
169
- | 月初日 | | first_day | number | Integer | 1 | x日(1日固定) |
170
- | 月初日の干支 | | | zodiac_name | String | 甲寅 | |
171
- | 月初日の大余小余 | | | remainder | String | 50-2479 | |
172
- | 西暦日 | | | western_date | String | 0937-02-13 | |
173
- | 節気 | | odd_solar_terms | | Zakuro::Result::Data::SolarTerm | | |
174
- | 二十四節気番号 | | | index | Integer | 5 | 番号(冬至0始まり) |
175
- | 二十四節気の大余小余 | | | remainder | String | 7-8293 | 大余小余 |
176
- | 中気 | | even_solar_terms | | Zakuro::Result::Data::SolarTerm | | |
177
- | 二十四節気番号 | | | index | Integer | 4 | 番号(冬至0始まり) |
178
- | 二十四節気の大余小余 | | | remainder | String | 52-6457 | 大余小余 |
179
- | 日 | day | | | Zakuro::Result::Data::Day | | |
180
- | 日番号 | | number | | Integer | 2 | x日 |
181
- | 日の干支 | | zodiac_name | | String | 乙卯 | 日の干支 |
182
- | 日の大余小余 | | remainder | | String | 51-2479 | 大余小余 |
183
- | 西暦日 | | western_date | | String | 0937-02-14 | 西暦日 |
184
- | オプション | options | | | Hash<String, Zakuro::Result::Data::Option::AbstractOption>| | オプション値 |
185
-
186
- ### Zakuro::Result::Operation
187
-
188
- | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
189
- |--------------|----------|------------|-------------|--------------------------------------------|---------|----------------------|
190
- | 運用有無 | operated |   |   | True/False | true |   |
191
- | 月別履歴情報 | month |   |   | Zakuro::Result::Operation::Month |   |   |
192
- | 計算値 | original |   |   | Zakuro::Result::Data::SingleDay |   | 運用値差替前の計算値 |
193
-
194
- ### Zakuro::Result::Operation::Month
195
-
196
- | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
197
- |--------------------------|----------|------------|----------|--------------------------------------------|--------------|---------------------------------------------|
198
- | 月別履歴情報(当月) | current |   |   | Zakuro::Result::Operation::Month::History | |該当月の履歴情報 |
199
- | 月別履歴情報(親) | parent |   |   | Zakuro::Result::Operation::Month::History |   |前後の月により副次的に影響を受けた時の履歴情報|
200
-
201
-
202
- ### Zakuro::Result::Operation::Month::History
203
-
204
- | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
205
- |-------------------|----------|--------------|-------------|----------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|----------------------|
206
- | ID | | id |   | String | 178-1-1 | zakuro内の一意なID |
207
- | 月初日の西暦日 | | western_date |   | String | 0937-02-13 | 計算値 |
208
- | 原文頁数 | | page |   | Integer | 178 |   |
209
- | 原文注釈番号 | | number |   | Integer | 1 |   |
210
- | 注釈 | | annotations |   | Array\<Zakuro::Result::Operation::MonthAnnotation\> |   |   |
211
- | 注釈内容 |   | | description | String | 計算は51乙卯であるが, 日本紀略に甲寅朔とある。<br>正月甲寅朔のユリウス暦日は2月13日となる。(元旦日食 をさけるための変更か) |   |
212
- | 注釈補記 |   | | note | String | - | 原文訂正 |
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 | |
74
+
75
+ [期待値](./doc/expection.md) を参照してください。
228
76
 
229
77
  # 元号
230
78
 
@@ -233,11 +81,33 @@ puts merchant.commit.to_json
233
81
  # 運用値
234
82
 
235
83
  一部の月では計算値から運用値への書き換えが発生します。
84
+
236
85
  経緯は [実運用](./doc/operation.md) を参照してください。
237
86
 
238
87
  # 暦算
239
88
 
240
- [宣明暦](./lib/zakuro/version/senmyou/README.md) のみ記載しております。
89
+ 暦算の解説は次の通りです。
90
+
91
+ ## 暦別
92
+
93
+ |暦 |有無|
94
+ |:----|:----|
95
+ |[元嘉暦](./doc/version/genka.md)|✓|
96
+ |[儀鳳暦](./doc/version/gihou.md)|✓|
97
+ |[大衍暦](./doc/version/daien.md)|✓|
98
+ |[宣明暦](./doc/version/senmyou.md)|✓|
99
+ |貞享暦|-|
100
+ |宝暦暦|-|
101
+ |寛政暦|-|
102
+ |天保暦|-|
103
+ |グレゴリオ暦|-|
104
+
105
+ ## 項目別
106
+
107
+ |項目 |有無|
108
+ |:----|:----|
109
+ |[没日](./doc/dropped_date.md)|✓|
110
+ |滅日|-|
241
111
 
242
112
  # 例外
243
113
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0
1
+ 0.9.1
data/doc/condition.md ADDED
@@ -0,0 +1,36 @@
1
+ # 条件
2
+
3
+ 条件(condition)のバリエーションを示します。
4
+
5
+ | 項目名 | キー名 | hash内キー名 | データ型 | 備考 |
6
+ |----------------|---------|--------------|----------|--------------------|
7
+ | 基準日 | date | | Date | 西暦日 |
8
+ | | | | String | 和暦日/西暦日 |
9
+ | 範囲(開始日) | range | start | Date | 西暦日 |
10
+ | | | | String | 和暦日/西暦日 |
11
+ | 範囲(終了日) | | last | Date | 西暦日 |
12
+ | | | | String | 和暦日/西暦日 |
13
+ | 列 | columns | | Array | 取得したい列の列名 |
14
+ | オプション | options | | Hash<String, Object> | 取得オプション |
15
+
16
+ 現時点では `date` と `range` のみ対応中です。
17
+
18
+ ## オプション
19
+
20
+ | 項目名 | キー名 | データ型 | データ | 備考 |
21
+ |--------|-----------|----------|--------|------------------------|
22
+ | 暦 | version | String | Genka | 元嘉暦 |
23
+ | | | | Gihou | 儀鳳暦 |
24
+ | | | | Daien | 大衍暦 |
25
+ | | | | Senmyou | 宣明暦 |
26
+ | | | | Joukyou | 貞享暦 |
27
+ | | | | Kansei | 寛政暦 |
28
+ | | | | Tenpou | 天保暦 |
29
+ | | | | Gregorio | グレゴリオ暦 |
30
+ | | | | | 指定なし(デフォルト) |
31
+ | 没日 | dropped_days | TRUE | | 没日あり |
32
+ | | | FALSE | | 没日なし(デフォルト) |
33
+ | 四季 | seasons | TRUE | | 四季あり |
34
+ | | | FALSE | | 四季なし(デフォルト) |
35
+
36
+ 現時点では宣明暦の [没日](./doc/dropped_date.md) のみ試験的に対応しております(結果未検証)。
data/doc/dropped_date.md CHANGED
@@ -7,6 +7,7 @@
7
7
  「日本暦日便覧」に従う
8
8
 
9
9
  ## 計算
10
+ ### 宣明暦
10
11
  「長慶宣明暦算法」に従う
11
12
 
12
13
  下記は該当箇所の引用と、それに対応する計算を示している
@@ -91,3 +92,43 @@
91
92
  * 大余 + 9
92
93
  * 小余 + 28260
93
94
  * 小余 > 44055 の場合は繰り上げ
95
+
96
+ ## 大衍暦
97
+ 『歴代天文律暦等志彙編 七』に従う
98
+
99
+ ### 本文
100
+
101
+ ```
102
+ 推没日 置有没之氣恆小餘, 以象統乗之, 内秒分, 参而伍之, 以減策實。餘満策餘, 為日。不満, 為没餘。命起也。〔四〕凡恆氣小餘, 不満大衍通法, 如中盈分半法已下, 為有没之氣。
103
+ ```
104
+ p.2056
105
+
106
+ ```
107
+ 大衍通法:三千四十。
108
+ 策實:一百十一萬三百四十三。
109
+ 策餘:一萬五千九百四十三。
110
+ 中盈分:一千三百二十八;秒,十四。
111
+ 象統:二十四。
112
+ ```
113
+ p.2055-2056
114
+
115
+ ### 定数
116
+ 計算方法は宣明暦と変わらない。定数のみ取りだす
117
+
118
+ ### 有没の気判定
119
+
120
+ `大衍通法` (3040) - ( `中盈分` (1328分14秒) / 2) = 3040分 - 664分7秒 = 2375分17秒
121
+
122
+ #### 小余倍率
123
+
124
+ 記載はないが宣明暦と変わらない
125
+
126
+ 360
127
+
128
+ #### 秒倍率
129
+
130
+ 360 / `象統` (24) = `参而伍` (3 * 5) = 15
131
+
132
+ #### 没余上限
133
+
134
+ `策餘` (15943)
data/doc/expection.md ADDED
@@ -0,0 +1,108 @@
1
+ # 期待値
2
+
3
+ 次の期待値を参照します。
4
+
5
+ |対象|文献|
6
+ |:----|:----|
7
+ |暦算値|『日本暦日原典〔第四版〕』|
8
+ |元号|『日本史年表 第5版』|
9
+ |没日・滅日|『日本暦日便覧』|
10
+
11
+ ## 種類
12
+
13
+ 現状は一日検索のみ対応しております。
14
+
15
+ | 項目名 | データ型 |
16
+ |----------|------------------------|
17
+ | 一日検索 | Zakuro::Result::Single |
18
+ | 範囲検索 | Zakuro::Result::Range |
19
+
20
+ ### Zakuro::Result::Single
21
+
22
+ | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考   |
23
+ |----------|-----------|---|---|-----------------------------------|--------|---------------------------------------|
24
+ | 日付情報 | data | | | Zakuro::Result::Data::SingleDay | - | 運用値(計算値は運用情報内を参照のこと)|
25
+ | 運用情報 | operation | | | Zakuro::Result::Operation | - | - |
26
+
27
+ ### Zakuro::Result::Range
28
+
29
+ | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考   |
30
+ |----------|-----------|---|---|---------------------------------------|--------|---------------------------------------|
31
+ | 日リスト | list | | | Array\<Zakuro::Result::Data::Single\> | - | 範囲内の日付情報すべて |
32
+
33
+ ### Zakuro::Result::SingleDay
34
+
35
+ | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
36
+ |--------------------------|--------|------------------|--------------|---------------------------------|------------|----------------------------|
37
+ | 年情報 | year | | | Zakuro::Result::Data::Year | | |
38
+ | 年号 | | first_gengou | | Zakuro::Result::Data::Gengou | | |
39
+ | 元号 | | | name | String | 承平 | |
40
+ | 元号年 | | | number | Integer | 7 | |
41
+ | 年号(南北朝時代の北朝) | | second_gengou | | Zakuro::Result::Data::Gengou | | |
42
+ | 元号 | | | name | String | - | 南北朝時代の北朝のみ |
43
+ | 元号年 | | | number | Integer | - | 南北朝時代の北朝のみ |
44
+ | 年の干支 | | zodiac_name | | String | 丁酉 | |
45
+ | 年の日数 | | total_days | | Integer | 354 | |
46
+ | 月 | month | | | Zakuro::Result::Data::Month | | |
47
+ | 月番号 | | number | | Integer | 1 | x月 |
48
+ | 閏月判定 | | leaped | | True/False | false | 閏月(true)/平月(false) |
49
+ | 月の大小 | | days_name | | String | 大 | 大(30日) / 小(29日) |
50
+ | 月初日 | | first_day | number | Integer | 1 | x日(1日固定) |
51
+ | 月初日の干支 | | | zodiac_name | String | 甲寅 | |
52
+ | 月初日の大余小余 | | | remainder | String | 50-2479 | |
53
+ | 西暦日 | | | western_date | String | 0937-02-13 | |
54
+ | 節気 | | odd_solar_terms | | Zakuro::Result::Data::SolarTerm | | |
55
+ | 二十四節気番号 | | | index | Integer | 5 | 番号(冬至0始まり) |
56
+ | 二十四節気の大余小余 | | | remainder | String | 7-8293 | 大余小余 |
57
+ | 中気 | | even_solar_terms | | Zakuro::Result::Data::SolarTerm | | |
58
+ | 二十四節気番号 | | | index | Integer | 4 | 番号(冬至0始まり) |
59
+ | 二十四節気の大余小余 | | | remainder | String | 52-6457 | 大余小余 |
60
+ | 日 | day | | | Zakuro::Result::Data::Day | | |
61
+ | 日番号 | | number | | Integer | 2 | x日 |
62
+ | 日の干支 | | zodiac_name | | String | 乙卯 | 日の干支 |
63
+ | 日の大余小余 | | remainder | | String | 51-2479 | 大余小余 |
64
+ | 西暦日 | | western_date | | String | 0937-02-14 | 西暦日 |
65
+ | オプション | options | | | Hash<String, Zakuro::Result::Data::Option::AbstractOption>| | オプション値 |
66
+
67
+ ### Zakuro::Result::Operation
68
+
69
+ | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
70
+ |--------------|----------|------------|-------------|--------------------------------------------|---------|----------------------|
71
+ | 運用有無 | operated |   |   | True/False | true |   |
72
+ | 月別履歴情報 | month |   |   | Zakuro::Result::Operation::Month |   |   |
73
+ | 計算値 | original |   |   | Zakuro::Result::Data::SingleDay |   | 運用値差替前の計算値 |
74
+
75
+ ### Zakuro::Result::Operation::Month
76
+
77
+ | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
78
+ |--------------------------|----------|------------|----------|--------------------------------------------|--------------|---------------------------------------------|
79
+ | 月別履歴情報(当月) | current |   |   | Zakuro::Result::Operation::Month::History | |該当月の履歴情報 |
80
+ | 月別履歴情報(親) | parent |   |   | Zakuro::Result::Operation::Month::History |   |前後の月により副次的に影響を受けた時の履歴情報|
81
+
82
+
83
+ ### Zakuro::Result::Operation::Month::History
84
+
85
+ | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
86
+ |-------------------|----------|--------------|-------------|----------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|----------------------|
87
+ | ID | | id |   | String | 178-1-1 | zakuro内の一意なID |
88
+ | 月初日の西暦日 | | western_date |   | String | 0937-02-13 | 計算値 |
89
+ | 原文頁数 | | page |   | Integer | 178 |   |
90
+ | 原文注釈番号 | | number |   | Integer | 1 |   |
91
+ | 注釈 | | annotations |   | Array\<Zakuro::Result::Operation::MonthAnnotation\> |   |   |
92
+ | 注釈内容 |   | | description | String | 計算は51乙卯であるが, 日本紀略に甲寅朔とある。<br>正月甲寅朔のユリウス暦日は2月13日となる。(元旦日食 をさけるための変更か) |   |
93
+ | 注釈補記 |   | | note | String | - | 原文訂正 |
94
+
95
+ ### Zakuro::Result::Data::Option::AbstractOption
96
+
97
+ #### Zakuro::Result::Data::Option::DroppedDate::Option
98
+
99
+ キー: dropped_date
100
+
101
+ | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
102
+ | -------------------- | ----------- | ---------- | --------- | ------------------------------------------------------ | -------- | ------------------ |
103
+ | オプション値有無 | matched | | | True/False | true | |
104
+ | 演算値 | calculation | | | Zakuro::Result::Data::Option::DroppedDate::Calculation | | |
105
+ | 没余 | | remainder | | String | 59-34155 | |
106
+ | 二十四節気 | | solar_term | | Zakuro::Result::Data::Option::DroppedDate::SolarTerm | | |
107
+ | 二十四節気番号 | | | index | Integer | 6 | |
108
+ | 二十四節気の大余小余 | | | remainder | String | 49-7203 | |
data/doc/usage.md ADDED
@@ -0,0 +1,120 @@
1
+ # 使用方法
2
+
3
+ 使用例は後述しております。
4
+
5
+ ## 手順
6
+
7
+ ### 条件設定
8
+
9
+ 期待する結果を得るためには、適切な条件を渡す必要があります。
10
+
11
+ 条件はHash型で渡します。
12
+
13
+ ```
14
+ require 'zakuro'
15
+
16
+ # 初期化時の設定
17
+ merchant = Zakuro::Merchant.new(condition: { date: Date.new(862, 2, 3) })
18
+ ```
19
+
20
+ 詳細は、 [条件](./condition.md) を参照してください。
21
+
22
+ ### 条件再設定
23
+
24
+ 一度設定した条件を書き換えることが可能です。
25
+
26
+ ```
27
+ # 再設定
28
+ merchant.offer(condition: { date: western_date })
29
+
30
+ # 条件を指定しない初期化
31
+ merchant = Zakuro::Merchant.new
32
+
33
+ # 後付けで条件を設定する
34
+ merchant.offer(condition: { date: western_date })
35
+ ```
36
+
37
+ ### 結果取得
38
+
39
+ #### JSON(整形なし)
40
+ ```
41
+ puts merchant.commit.to_json
42
+ # => {"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":{}}}}
43
+ ```
44
+
45
+ #### JSON(整形あり)
46
+
47
+ 行数が多いため結果は省略します。
48
+ ```
49
+ puts merchant.commit.to_pretty_json
50
+ # => {
51
+ "data": {
52
+ "year": {
53
+ "first_gengou": {
54
+ "name": "貞観",
55
+ "number": 4
56
+ },
57
+ "second_gengou": {
58
+ "name": "",
59
+ "number": -1
60
+ },
61
+ "zodiac_name": "壬午",
62
+ "total_days": 354
63
+ },
64
+ # 中略
65
+ }
66
+ }
67
+ ```
68
+
69
+ ## 使用例
70
+
71
+ ### 一日検索(西暦 -> 和暦)
72
+
73
+ ```
74
+ require 'zakuro'
75
+
76
+ # 条件となる西暦日を準備する
77
+ western_date = Date.new(862, 2, 3)
78
+
79
+ # ざくろ商人(Zakuro::Merchant)に西暦日を渡す
80
+ merchant = Zakuro::Merchant.new(condition: { date: western_date })
81
+
82
+ # 結果の和暦日を取得する
83
+ puts merchant.commit.to_json
84
+ # => {"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":{}}}}
85
+
86
+ ```
87
+
88
+ ### 一日検索(和暦 -> 和暦)
89
+
90
+ ```
91
+ require 'zakuro'
92
+
93
+ # 条件となる和暦日を準備する
94
+ japan_date = '貞観4年1月1日'
95
+
96
+ # ざくろ商人(Zakuro::Merchant)に和暦日を渡す
97
+ merchant = Zakuro::Merchant.new(condition: { date: japan_date })
98
+
99
+ # 結果の和暦日を取得する
100
+ puts merchant.commit.to_json
101
+ # => {"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":{}}}}
102
+ ```
103
+
104
+ ### 範囲検索(西暦 -> 和暦)
105
+
106
+ ```
107
+ merchant = Zakuro::Merchant.new(condition: { range: {start: Date.new(862, 2, 3), last: Date.new(862, 2, 4)
108
+ } })
109
+
110
+ puts merchant.commit.to_json
111
+ # => {"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":{}}}}]}
112
+ ```
113
+
114
+ ### 範囲検索(和暦 -> 和暦)
115
+
116
+ ```
117
+ merchant = Zakuro::Merchant.new(condition: { range: {start: '貞観4年1月1日', last: '貞観4年1月2日' } })
118
+ puts merchant.commit.to_json
119
+ # => {"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":{}}}}]}
120
+ ```