zakuro 0.9.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/README.md +41 -8
- data/VERSION +1 -1
- data/doc/gengou.md +1 -1
- data/doc/operation/csv/month.csv +5 -5
- data/doc/operation/operation.xlsx +0 -0
- data/images/logo-text.png +0 -0
- data/lib/zakuro/calculation/base/gengou.rb +2 -4
- data/lib/zakuro/calculation/base/year.rb +1 -1
- data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +2 -2
- data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +1 -1
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +4 -4
- data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +3 -3
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +1 -1
- data/lib/zakuro/calculation/era/version/internal/crawler.rb +3 -3
- data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +1 -1
- data/lib/zakuro/calculation/monthly/internal/date_comparer.rb +78 -0
- data/lib/zakuro/calculation/monthly/{meta → internal/meta}/all_solar_term.rb +1 -1
- data/lib/zakuro/calculation/monthly/{meta → internal/meta}/meta_collector.rb +2 -2
- data/lib/zakuro/calculation/monthly/{first_day.rb → internal/part/first_day.rb} +2 -2
- data/lib/zakuro/calculation/monthly/{meta.rb → internal/part/meta.rb} +1 -1
- data/lib/zakuro/calculation/monthly/internal/solar_term_selector.rb +203 -0
- data/lib/zakuro/calculation/monthly/month.rb +30 -125
- data/lib/zakuro/calculation/monthly/operated_month.rb +5 -2
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +0 -2
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +24 -10
- data/lib/zakuro/calculation/stella/solar/abstract_average.rb +3 -3
- data/lib/zakuro/calculation/summary/internal/option/dropped_date.rb +102 -0
- data/lib/zakuro/calculation/summary/internal/option/vanished_date.rb +111 -0
- data/lib/zakuro/calculation/summary/internal/option.rb +4 -137
- data/lib/zakuro/calculation/summary/japan/range.rb +4 -5
- data/lib/zakuro/calculation/summary/western/single.rb +0 -2
- data/lib/zakuro/context/version_class_resolver.rb +5 -5
- data/lib/zakuro/era/japan/calendar.rb +4 -4
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +2 -2
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +2 -2
- data/lib/zakuro/era/japan/gengou/alignment.rb +5 -3
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +17 -16
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +3 -394
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml +2 -2
- data/lib/zakuro/era/japan/gengou.rb +3 -3
- data/lib/zakuro/era/japan/type/base/both/date.rb +51 -0
- data/lib/zakuro/era/japan/type/base/both/year.rb +53 -0
- data/lib/zakuro/era/japan/type/base/gengou.rb +177 -0
- data/lib/zakuro/era/japan/type/base/gengou_set.rb +78 -0
- data/lib/zakuro/era/japan/type/base/switch_date.rb +74 -0
- data/lib/zakuro/era/japan/type/base/version_range.rb +189 -0
- data/lib/zakuro/era/japan/type/validation/both/date.rb +99 -0
- data/lib/zakuro/era/japan/type/validation/both/year.rb +75 -0
- data/lib/zakuro/era/japan/type/validation/gengou.rb +93 -0
- data/lib/zakuro/era/japan/type/validation/gengou_set.rb +133 -0
- data/lib/zakuro/era/japan/type/validation/switch_date.rb +73 -0
- data/lib/zakuro/era/japan/type/validation/version_range.rb +109 -0
- data/lib/zakuro/era/japan/type/validation/version_root.rb +102 -0
- data/lib/zakuro/era/japan/version/resource/parser.rb +266 -0
- data/lib/zakuro/era/japan/version/resource/validator.rb +37 -0
- data/lib/zakuro/era/japan/version/resource/yaml/version.yaml +80 -0
- data/lib/zakuro/era/japan/version/resource.rb +22 -0
- data/lib/zakuro/era/japan/version.rb +4 -115
- data/lib/zakuro/era/western/calendar.rb +2 -2
- data/lib/zakuro/exception/zakuro_error.rb +1 -1
- data/lib/zakuro/merchant.rb +5 -5
- data/lib/zakuro/operation/month/parser.rb +2 -2
- data/lib/zakuro/operation/yaml/month.yaml +5 -5
- data/lib/zakuro/output/logger.rb +4 -4
- data/lib/zakuro/parameter/catalog/basis_date.rb +55 -0
- data/lib/zakuro/parameter/catalog/column.rb +57 -0
- data/lib/zakuro/parameter/catalog/option.rb +60 -0
- data/lib/zakuro/parameter/catalog/range.rb +81 -0
- data/lib/zakuro/parameter/condition.rb +108 -0
- data/lib/zakuro/result/core.rb +2 -2
- data/lib/zakuro/{tools → tool}/remainder_comparer.rb +2 -4
- data/lib/zakuro/{tools → tool}/stringifier.rb +3 -3
- data/lib/zakuro/{tools → tool}/typeconv.rb +2 -2
- data/lib/zakuro/{tools → tool}/typeof.rb +2 -2
- data/lib/zakuro/version/daien/const/number.rb +42 -39
- data/lib/zakuro/version/daien/const/remainder.rb +38 -35
- data/lib/zakuro/version/daien/cycle/remainder.rb +77 -74
- data/lib/zakuro/version/daien/cycle/solar_term.rb +18 -15
- data/lib/zakuro/version/daien/daien.rb +8 -5
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +67 -64
- data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +15 -12
- data/lib/zakuro/version/daien/option/vanished_date/parameter.rb +15 -12
- data/lib/zakuro/version/daien/range/annual_range.rb +27 -24
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +209 -206
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +32 -29
- data/lib/zakuro/version/daien/stella/lunar/location.rb +53 -50
- data/lib/zakuro/version/daien/stella/lunar/value.rb +65 -62
- data/lib/zakuro/version/daien/stella/origin/average_november.rb +23 -20
- data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +42 -39
- data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +44 -41
- data/lib/zakuro/version/daien/stella/solar/adjustment.rb +74 -71
- data/lib/zakuro/version/daien/stella/solar/average.rb +68 -65
- data/lib/zakuro/version/daien/stella/solar/interval.rb +95 -92
- data/lib/zakuro/version/daien/stella/solar/location.rb +41 -38
- data/lib/zakuro/version/daien/stella/solar/value.rb +21 -18
- data/lib/zakuro/version/genka/const/number.rb +31 -28
- data/lib/zakuro/version/genka/const/remainder.rb +20 -17
- data/lib/zakuro/version/genka/cycle/remainder.rb +72 -69
- data/lib/zakuro/version/genka/cycle/solar_term.rb +18 -15
- data/lib/zakuro/version/genka/genka.rb +8 -5
- data/lib/zakuro/version/genka/monthly/lunar_phase.rb +82 -79
- data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +13 -10
- data/lib/zakuro/version/genka/option/vanished_date/parameter.rb +13 -10
- data/lib/zakuro/version/genka/range/annual_range.rb +57 -54
- data/lib/zakuro/version/genka/stella/origin/first_term.rb +44 -41
- data/lib/zakuro/version/genka/stella/origin/january.rb +38 -35
- data/lib/zakuro/version/genka/stella/solar/average.rb +24 -21
- data/lib/zakuro/version/gihou/const/number.rb +40 -37
- data/lib/zakuro/version/gihou/const/remainder.rb +32 -29
- data/lib/zakuro/version/gihou/cycle/remainder.rb +38 -35
- data/lib/zakuro/version/gihou/cycle/solar_term.rb +18 -15
- data/lib/zakuro/version/gihou/gihou.rb +8 -5
- data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +68 -65
- data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +13 -10
- data/lib/zakuro/version/gihou/option/vanished_date/parameter.rb +13 -10
- data/lib/zakuro/version/gihou/range/annual_range.rb +27 -24
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +212 -209
- data/lib/zakuro/version/gihou/stella/lunar/localization.rb +32 -29
- data/lib/zakuro/version/gihou/stella/lunar/location.rb +53 -50
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +65 -62
- data/lib/zakuro/version/gihou/stella/origin/average_november.rb +23 -20
- data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +42 -39
- data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +44 -41
- data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +74 -71
- data/lib/zakuro/version/gihou/stella/solar/average.rb +67 -64
- data/lib/zakuro/version/gihou/stella/solar/interval.rb +95 -92
- data/lib/zakuro/version/gihou/stella/solar/location.rb +41 -38
- data/lib/zakuro/version/gihou/stella/solar/value.rb +21 -18
- data/lib/zakuro/version/gregorio/gregorio.rb +8 -5
- data/lib/zakuro/version/houryaku/houryaku.rb +8 -5
- data/lib/zakuro/version/joukyou/joukyou.rb +8 -5
- data/lib/zakuro/version/kansei/kansei.rb +8 -5
- data/lib/zakuro/version/senmyou/const/number.rb +40 -37
- data/lib/zakuro/version/senmyou/const/remainder.rb +35 -32
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +74 -71
- data/lib/zakuro/version/senmyou/cycle/solar_term.rb +18 -15
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +69 -66
- data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +15 -12
- data/lib/zakuro/version/senmyou/option/vanished_date/parameter.rb +15 -12
- data/lib/zakuro/version/senmyou/range/annual_range.rb +27 -24
- data/lib/zakuro/version/senmyou/senmyou.rb +8 -5
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +206 -203
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +32 -29
- data/lib/zakuro/version/senmyou/stella/lunar/location.rb +60 -57
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +66 -63
- data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +23 -20
- data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +42 -39
- data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +44 -41
- data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +74 -71
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +67 -64
- data/lib/zakuro/version/senmyou/stella/solar/interval.rb +93 -90
- data/lib/zakuro/version/senmyou/stella/solar/location.rb +41 -38
- data/lib/zakuro/version/senmyou/stella/solar/value.rb +23 -20
- data/lib/zakuro/version/tenpou/tenpou.rb +8 -5
- metadata +44 -20
- data/lib/zakuro/condition.rb +0 -306
- data/lib/zakuro/era/japan/gengou/resource/type.rb +0 -356
- data/lib/zakuro/tools/gengou_range_comparer.rb +0 -82
- /data/lib/zakuro/calculation/monthly/{operated_solar_term.rb → internal/operated_solar_term.rb} +0 -0
- /data/lib/zakuro/calculation/monthly/{const.rb → internal/part/const.rb} +0 -0
- /data/lib/zakuro/calculation/monthly/{month_label.rb → internal/part/month_label.rb} +0 -0
@@ -5,248 +5,251 @@ require_relative '../../const/number'
|
|
5
5
|
# :nodoc:
|
6
6
|
module Zakuro
|
7
7
|
# :nodoc:
|
8
|
-
module
|
8
|
+
module Version
|
9
9
|
# :nodoc:
|
10
|
-
module
|
11
|
-
#
|
12
|
-
|
13
|
-
#
|
14
|
-
module Adjustment
|
10
|
+
module Gihou
|
11
|
+
# :nodoc:
|
12
|
+
module Lunar
|
15
13
|
#
|
16
|
-
#
|
14
|
+
# Adjustment 補正値情報
|
17
15
|
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
class Row
|
43
|
-
# @return [Integer] 入暦(1-14)
|
44
|
-
attr_reader :day
|
45
|
-
# @return [Range] 小余範囲
|
46
|
-
attr_reader :range
|
47
|
-
# @return [Value] 補正値
|
48
|
-
attr_reader :value
|
16
|
+
module Adjustment
|
17
|
+
#
|
18
|
+
# 遠/近の地点での中間
|
19
|
+
#
|
20
|
+
# 7、14、21日の小余の境界は下記のようにして求めた
|
21
|
+
# * 宣明暦の7日の小余は7465である。入暦は1始まりなので、0始まりで表現すると 6-7465 となる
|
22
|
+
# * 6 * 8400(統法) + 7465(初益) = 57865
|
23
|
+
# * これを儀鳳暦に変えると、 57865 / 1340(総法) = 6 余り 1190.845238..
|
24
|
+
# * これを入暦の1始まりに置き換え、少数部を消すと 7-1190、これが7日目となる
|
25
|
+
# * 同様の方法で14日と21日も求める
|
26
|
+
# * 57865 * 2 = 115730 / 1340(総法) = 13 余り 1041.690476 = 14-1041
|
27
|
+
# * 57865 * 3 = 173595 / 1340(総法) = 20 余り 892.5357143 = 21-892
|
28
|
+
#
|
29
|
+
# 28日は変日の範囲内743とした。
|
30
|
+
# * 宣明暦では 進退 14-6529(1始まりなので実質13) * 2 = 27-4658
|
31
|
+
# * 暦周 27-4658.19 に一致する。これを変日27-743.1と同等とみなした
|
32
|
+
#
|
33
|
+
# @return [Hash<Integer>] 遠/近の地点での中間
|
34
|
+
DAY_LIMIT = {
|
35
|
+
7 => 1191, # 天平勝宝2年(750年)5月 により 1190 ではないことを確認した
|
36
|
+
14 => 1042, # 養老6年(722年) 6月 により 1041 ではないことを確認した
|
37
|
+
21 => 892,
|
38
|
+
28 => 743.06 # 天平13年(741年) 2月 により 743 ではないことを確認した
|
39
|
+
}.freeze
|
49
40
|
|
50
41
|
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
# @param [Integer] day 入暦(1-14)
|
54
|
-
# @param [Range] range 小余範囲
|
55
|
-
# @param [Value] value 補正値
|
42
|
+
# Row 行情報
|
56
43
|
#
|
57
|
-
|
58
|
-
@
|
59
|
-
|
60
|
-
@
|
61
|
-
|
44
|
+
class Row
|
45
|
+
# @return [Integer] 入暦(1-14)
|
46
|
+
attr_reader :day
|
47
|
+
# @return [Range] 小余範囲
|
48
|
+
attr_reader :range
|
49
|
+
# @return [Value] 補正値
|
50
|
+
attr_reader :value
|
51
|
+
|
52
|
+
#
|
53
|
+
# 初期化
|
54
|
+
#
|
55
|
+
# @param [Integer] day 入暦(1-14)
|
56
|
+
# @param [Range] range 小余範囲
|
57
|
+
# @param [Value] value 補正値
|
58
|
+
#
|
59
|
+
def initialize(day:, range:, value:)
|
60
|
+
@day = day
|
61
|
+
@range = range
|
62
|
+
@value = value
|
63
|
+
end
|
62
64
|
|
63
|
-
|
65
|
+
# :reek:ControlParameter
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
67
|
+
#
|
68
|
+
# 一致するか
|
69
|
+
#
|
70
|
+
# @param [Integer] day 入暦(1-14)
|
71
|
+
# @param [Integer] minute 小余
|
72
|
+
#
|
73
|
+
# @return [True] 一致
|
74
|
+
# @return [False] 不一致
|
75
|
+
#
|
76
|
+
def match?(day:, minute:)
|
77
|
+
inner_day = @day
|
78
|
+
return false unless inner_day == day
|
79
|
+
|
80
|
+
return false unless range.include?(minute: minute)
|
77
81
|
|
78
|
-
|
82
|
+
true
|
83
|
+
end
|
79
84
|
|
80
|
-
|
85
|
+
#
|
86
|
+
# 分母を返す
|
87
|
+
#
|
88
|
+
# @return [Integer] 分母
|
89
|
+
#
|
90
|
+
def denominator
|
91
|
+
range.denominator
|
92
|
+
end
|
81
93
|
end
|
82
94
|
|
83
95
|
#
|
84
|
-
#
|
96
|
+
# Range 小余範囲
|
85
97
|
#
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
98
|
+
class Range
|
99
|
+
# @return [Integer] 下限
|
100
|
+
MIN = 0
|
101
|
+
# @return [Integer] 上限
|
102
|
+
MAX = Const::Number::Cycle::DAY
|
92
103
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
# @return [Integer] 下限
|
98
|
-
MIN = 0
|
99
|
-
# @return [Integer] 上限
|
100
|
-
MAX = Const::Number::Cycle::DAY
|
104
|
+
# @return [Integer] 下限
|
105
|
+
attr_reader :min
|
106
|
+
# @return [Integer] 上限
|
107
|
+
attr_reader :max
|
101
108
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
109
|
+
#
|
110
|
+
# 初期化
|
111
|
+
#
|
112
|
+
# @param [Integer] min 下限
|
113
|
+
# @param [Integer] max 上限
|
114
|
+
#
|
115
|
+
def initialize(min: MIN, max: MAX)
|
116
|
+
@min = min
|
117
|
+
@max = max
|
118
|
+
end
|
106
119
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
120
|
+
#
|
121
|
+
# 含まれるか
|
122
|
+
#
|
123
|
+
# @param [Integer] minute 小余
|
124
|
+
#
|
125
|
+
# @return [True] 含まれる
|
126
|
+
# @return [False] 含まれない
|
127
|
+
#
|
128
|
+
def include?(minute:)
|
129
|
+
minute >= min && minute <= max
|
130
|
+
end
|
117
131
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
def include?(minute:)
|
127
|
-
minute >= min && minute <= max
|
132
|
+
#
|
133
|
+
# 分母を返す
|
134
|
+
#
|
135
|
+
# @return [Integer] 分母
|
136
|
+
#
|
137
|
+
def denominator
|
138
|
+
max - min
|
139
|
+
end
|
128
140
|
end
|
129
141
|
|
130
142
|
#
|
131
|
-
#
|
132
|
-
#
|
133
|
-
# @return [Integer] 分母
|
143
|
+
# Value 補正値
|
134
144
|
#
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
145
|
+
class Value
|
146
|
+
# @return [Integer] 増減率
|
147
|
+
attr_reader :per
|
148
|
+
# @return [Integer] 遅速積
|
149
|
+
attr_reader :stack
|
139
150
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
151
|
+
#
|
152
|
+
# 初期化
|
153
|
+
#
|
154
|
+
# @param [Integer] per 増減率
|
155
|
+
# @param [Integer] stack 遅速積
|
156
|
+
#
|
157
|
+
def initialize(per:, stack:)
|
158
|
+
@per = per
|
159
|
+
@stack = stack
|
160
|
+
end
|
148
161
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
@stack = stack
|
162
|
+
#
|
163
|
+
# 文字化
|
164
|
+
#
|
165
|
+
# @return [String] 文字
|
166
|
+
#
|
167
|
+
def to_s
|
168
|
+
"per:#{per}, stack:#{stack}"
|
169
|
+
end
|
158
170
|
end
|
159
171
|
|
160
|
-
#
|
161
|
-
# 文字化
|
162
|
-
#
|
163
|
-
# @return [String] 文字
|
164
|
-
#
|
165
|
-
def to_s
|
166
|
-
"per:#{per}, stack:#{stack}"
|
167
|
-
end
|
168
|
-
end
|
172
|
+
# rubocop:disable Layout/LineLength
|
169
173
|
|
170
|
-
|
174
|
+
# @note 7日、14日、21日、28日の小余は DAY_LIMIT を参照のこと
|
175
|
+
#
|
176
|
+
# @return [Array<Row>] 月の補正値情報
|
177
|
+
#
|
178
|
+
LIST = [
|
179
|
+
Row.new(day: 1, range: Range.new, value: Value.new(per: -134, stack: 0)),
|
180
|
+
Row.new(day: 2, range: Range.new, value: Value.new(per: -117, stack: -134)),
|
181
|
+
Row.new(day: 3, range: Range.new, value: Value.new(per: -99, stack: -251)),
|
182
|
+
Row.new(day: 4, range: Range.new, value: Value.new(per: -78, stack: -350)),
|
183
|
+
Row.new(day: 5, range: Range.new, value: Value.new(per: -56, stack: -428)),
|
184
|
+
Row.new(day: 6, range: Range.new, value: Value.new(per: -33, stack: -484)),
|
185
|
+
Row.new(day: 7, range: Range.new(max: DAY_LIMIT[7]), value: Value.new(per: -9, stack: -517)),
|
186
|
+
Row.new(day: 7, range: Range.new(min: DAY_LIMIT[7]), value: Value.new(per: 0, stack: -526)),
|
187
|
+
Row.new(day: 8, range: Range.new, value: Value.new(per: +14, stack: -526)),
|
188
|
+
Row.new(day: 9, range: Range.new, value: Value.new(per: +38, stack: -512)),
|
189
|
+
Row.new(day: 10, range: Range.new, value: Value.new(per: +62, stack: -474)),
|
190
|
+
Row.new(day: 11, range: Range.new, value: Value.new(per: +85, stack: -412)),
|
191
|
+
Row.new(day: 12, range: Range.new, value: Value.new(per: +104, stack: -327)),
|
192
|
+
Row.new(day: 13, range: Range.new, value: Value.new(per: +121, stack: -223)),
|
193
|
+
Row.new(day: 14, range: Range.new(max: DAY_LIMIT[14]), value: Value.new(per: +102, stack: -102)),
|
194
|
+
Row.new(day: 14, range: Range.new(min: DAY_LIMIT[14]), value: Value.new(per: +29, stack: 0)),
|
195
|
+
Row.new(day: 15, range: Range.new, value: Value.new(per: +128, stack: +29)),
|
196
|
+
Row.new(day: 16, range: Range.new, value: Value.new(per: +115, stack: +157)),
|
197
|
+
Row.new(day: 17, range: Range.new, value: Value.new(per: +95, stack: +272)),
|
198
|
+
Row.new(day: 18, range: Range.new, value: Value.new(per: +74, stack: +367)),
|
199
|
+
Row.new(day: 19, range: Range.new, value: Value.new(per: +52, stack: +441)),
|
200
|
+
Row.new(day: 20, range: Range.new, value: Value.new(per: +28, stack: +493)),
|
201
|
+
Row.new(day: 21, range: Range.new(max: DAY_LIMIT[21]), value: Value.new(per: +4, stack: +521)),
|
202
|
+
Row.new(day: 21, range: Range.new(min: DAY_LIMIT[21]), value: Value.new(per: 0, stack: +525)),
|
203
|
+
Row.new(day: 22, range: Range.new, value: Value.new(per: -20, stack: +525)),
|
204
|
+
Row.new(day: 23, range: Range.new, value: Value.new(per: -44, stack: +505)),
|
205
|
+
Row.new(day: 24, range: Range.new, value: Value.new(per: -68, stack: +461)),
|
206
|
+
Row.new(day: 25, range: Range.new, value: Value.new(per: -89, stack: +393)),
|
207
|
+
Row.new(day: 26, range: Range.new, value: Value.new(per: -108, stack: +304)),
|
208
|
+
Row.new(day: 27, range: Range.new, value: Value.new(per: -125, stack: +196)),
|
209
|
+
Row.new(day: 28, range: Range.new(max: DAY_LIMIT[28]), value: Value.new(per: -71, stack: +71))
|
210
|
+
].freeze
|
211
|
+
# rubocop:enable Layout/LineLength
|
171
212
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
Row.new(day: 12, range: Range.new, value: Value.new(per: +104, stack: -327)),
|
190
|
-
Row.new(day: 13, range: Range.new, value: Value.new(per: +121, stack: -223)),
|
191
|
-
Row.new(day: 14, range: Range.new(max: DAY_LIMIT[14]), value: Value.new(per: +102, stack: -102)),
|
192
|
-
Row.new(day: 14, range: Range.new(min: DAY_LIMIT[14]), value: Value.new(per: +29, stack: 0)),
|
193
|
-
Row.new(day: 15, range: Range.new, value: Value.new(per: +128, stack: +29)),
|
194
|
-
Row.new(day: 16, range: Range.new, value: Value.new(per: +115, stack: +157)),
|
195
|
-
Row.new(day: 17, range: Range.new, value: Value.new(per: +95, stack: +272)),
|
196
|
-
Row.new(day: 18, range: Range.new, value: Value.new(per: +74, stack: +367)),
|
197
|
-
Row.new(day: 19, range: Range.new, value: Value.new(per: +52, stack: +441)),
|
198
|
-
Row.new(day: 20, range: Range.new, value: Value.new(per: +28, stack: +493)),
|
199
|
-
Row.new(day: 21, range: Range.new(max: DAY_LIMIT[21]), value: Value.new(per: +4, stack: +521)),
|
200
|
-
Row.new(day: 21, range: Range.new(min: DAY_LIMIT[21]), value: Value.new(per: 0, stack: +525)),
|
201
|
-
Row.new(day: 22, range: Range.new, value: Value.new(per: -20, stack: +525)),
|
202
|
-
Row.new(day: 23, range: Range.new, value: Value.new(per: -44, stack: +505)),
|
203
|
-
Row.new(day: 24, range: Range.new, value: Value.new(per: -68, stack: +461)),
|
204
|
-
Row.new(day: 25, range: Range.new, value: Value.new(per: -89, stack: +393)),
|
205
|
-
Row.new(day: 26, range: Range.new, value: Value.new(per: -108, stack: +304)),
|
206
|
-
Row.new(day: 27, range: Range.new, value: Value.new(per: -125, stack: +196)),
|
207
|
-
Row.new(day: 28, range: Range.new(max: DAY_LIMIT[28]), value: Value.new(per: -71, stack: +71))
|
208
|
-
].freeze
|
209
|
-
# rubocop:enable Layout/LineLength
|
210
|
-
|
211
|
-
class << self
|
212
|
-
#
|
213
|
-
# 月軌道の補正に必要な基本値を引き当てる
|
214
|
-
#
|
215
|
-
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
216
|
-
# @param [Integer] day 大余
|
217
|
-
# @param [Integer] minute 小余
|
218
|
-
#
|
219
|
-
# @return [Row] 補正値
|
220
|
-
#
|
221
|
-
# @raise [ArgumentError] 引数エラー
|
222
|
-
#
|
223
|
-
def specify(day:, minute:)
|
224
|
-
LIST.each do |row|
|
225
|
-
# NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
|
226
|
-
return row if row.match?(day: day, minute: minute)
|
227
|
-
end
|
213
|
+
class << self
|
214
|
+
#
|
215
|
+
# 月軌道の補正に必要な基本値を引き当てる
|
216
|
+
#
|
217
|
+
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
218
|
+
# @param [Integer] day 大余
|
219
|
+
# @param [Integer] minute 小余
|
220
|
+
#
|
221
|
+
# @return [Row] 補正値
|
222
|
+
#
|
223
|
+
# @raise [ArgumentError] 引数エラー
|
224
|
+
#
|
225
|
+
def specify(day:, minute:)
|
226
|
+
LIST.each do |row|
|
227
|
+
# NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
|
228
|
+
return row if row.match?(day: day, minute: minute)
|
229
|
+
end
|
228
230
|
|
229
|
-
|
230
|
-
|
231
|
+
raise ArgumentError.new, "invalid parameter: #{day}/#{minute}"
|
232
|
+
end
|
231
233
|
|
232
|
-
|
234
|
+
# :reek:ControlParameter
|
233
235
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
236
|
+
#
|
237
|
+
# 小余の下げ幅を求める
|
238
|
+
#
|
239
|
+
# @param [Integer] day 大余
|
240
|
+
# @param [Integer] minute 小余
|
241
|
+
#
|
242
|
+
# @return [Integer] 小余の下げ幅
|
243
|
+
#
|
244
|
+
def minus_minute(day:, minute:)
|
245
|
+
limit = DAY_LIMIT.fetch(day, -1)
|
246
|
+
# 該当なし
|
247
|
+
return minute if limit == -1
|
246
248
|
|
247
|
-
|
249
|
+
return minute unless minute > limit
|
248
250
|
|
249
|
-
|
251
|
+
minute - limit
|
252
|
+
end
|
250
253
|
end
|
251
254
|
end
|
252
255
|
end
|
@@ -5,39 +5,42 @@ require_relative '../../const/number'
|
|
5
5
|
# :nodoc:
|
6
6
|
module Zakuro
|
7
7
|
# :nodoc:
|
8
|
-
module
|
8
|
+
module Version
|
9
9
|
# :nodoc:
|
10
|
-
module
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
10
|
+
module Gihou
|
11
|
+
# :nodoc:
|
12
|
+
module Lunar
|
13
|
+
#
|
14
|
+
# Localization 入暦特定
|
15
|
+
#
|
16
|
+
module Localization
|
17
|
+
# @return [Integer] 1近点月
|
18
|
+
ANOMALISTIC_MONTH = Const::Number::Cycle::ANOMALISTIC_MONTH
|
19
|
+
# @return [Integer] 積年
|
20
|
+
TOTAL_YEAR = Const::Number::Stack::TOTAL_YEAR
|
21
|
+
# @return [Integer] 開始年
|
22
|
+
BEGIN_YEAR = Const::Number::Stack::BEGIN_YEAR
|
23
|
+
# @return [Integer] 年
|
24
|
+
YEAR = Const::Number::Cycle::YEAR
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
class << self
|
27
|
+
#
|
28
|
+
# 対象年の最初の入暦を求める
|
29
|
+
#
|
30
|
+
# @param [Remainder] lunar_age 天正閏余
|
31
|
+
# @param [Integer] western_year 西暦年
|
32
|
+
#
|
33
|
+
# @return [Cycle::LunarRemainder] 入暦
|
34
|
+
#
|
35
|
+
def first_remainder(lunar_age:, western_year:)
|
36
|
+
# 積年の開始から対象年までの年数
|
37
|
+
total_year = TOTAL_YEAR + western_year - BEGIN_YEAR
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
+
# 通積分 - 天正閏余
|
40
|
+
total_day = total_year * YEAR - lunar_age.to_minute
|
39
41
|
|
40
|
-
|
42
|
+
Cycle::LunarRemainder.new(total: (total_day % ANOMALISTIC_MONTH))
|
43
|
+
end
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -9,67 +9,70 @@ require_relative './localization'
|
|
9
9
|
# :nodoc:
|
10
10
|
module Zakuro
|
11
11
|
# :nodoc:
|
12
|
-
module
|
12
|
+
module Version
|
13
13
|
# :nodoc:
|
14
|
-
module
|
15
|
-
#
|
16
|
-
|
17
|
-
#
|
18
|
-
class Location < Calculation::Lunar::AbstractLocation
|
19
|
-
# @return [Cycle::LunarRemainder] 1近点月
|
20
|
-
ANOMALISTIC_MONTH = Const::Remainder::Lunar::ANOMALISTIC_MONTH
|
21
|
-
# @return [Cycle::LunarRemainder] 弦
|
22
|
-
QUARTER = Const::Remainder::Lunar::QUARTER
|
23
|
-
|
24
|
-
#
|
25
|
-
# 初期化
|
14
|
+
module Gihou
|
15
|
+
# :nodoc:
|
16
|
+
module Lunar
|
26
17
|
#
|
27
|
-
#
|
28
|
-
# @param [Integer] western_year 西暦年
|
18
|
+
# Location 入暦
|
29
19
|
#
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
)
|
36
|
-
end
|
20
|
+
class Location < Calculation::Lunar::AbstractLocation
|
21
|
+
# @return [Cycle::LunarRemainder] 1近点月
|
22
|
+
ANOMALISTIC_MONTH = Const::Remainder::Lunar::ANOMALISTIC_MONTH
|
23
|
+
# @return [Cycle::LunarRemainder] 弦
|
24
|
+
QUARTER = Const::Remainder::Lunar::QUARTER
|
37
25
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
26
|
+
#
|
27
|
+
# 初期化
|
28
|
+
#
|
29
|
+
# @param [Cycle::LunarRemainder] lunar_age 天正閏余(大余小余)
|
30
|
+
# @param [Integer] western_year 西暦年
|
31
|
+
#
|
32
|
+
def initialize(lunar_age:, western_year:)
|
33
|
+
super(
|
34
|
+
lunar_age: lunar_age,
|
35
|
+
quarter: QUARTER,
|
36
|
+
western_year: western_year
|
37
|
+
)
|
45
38
|
end
|
46
39
|
|
47
|
-
|
48
|
-
|
40
|
+
#
|
41
|
+
# 入暦を計算する
|
42
|
+
#
|
43
|
+
def run
|
44
|
+
if calculated
|
45
|
+
decrease(limit: ANOMALISTIC_MONTH)
|
46
|
+
return
|
47
|
+
end
|
49
48
|
|
50
|
-
|
49
|
+
first
|
50
|
+
end
|
51
51
|
|
52
|
-
|
53
|
-
# 初回計算
|
54
|
-
#
|
55
|
-
def first
|
56
|
-
@remainder = Localization.first_remainder(
|
57
|
-
lunar_age: remainder, western_year: western_year
|
58
|
-
)
|
59
|
-
decrease(limit: ANOMALISTIC_MONTH)
|
52
|
+
private
|
60
53
|
|
61
|
-
|
62
|
-
|
54
|
+
#
|
55
|
+
# 初回計算
|
56
|
+
#
|
57
|
+
def first
|
58
|
+
@remainder = Localization.first_remainder(
|
59
|
+
lunar_age: remainder, western_year: western_year
|
60
|
+
)
|
61
|
+
decrease(limit: ANOMALISTIC_MONTH)
|
63
62
|
|
64
|
-
|
65
|
-
|
66
|
-
#
|
67
|
-
# @param [Cycle::LunarRemainder] limit 上限
|
68
|
-
#
|
69
|
-
def decrease(limit:)
|
70
|
-
return if remainder < limit
|
63
|
+
@calculated = true
|
64
|
+
end
|
71
65
|
|
72
|
-
|
66
|
+
#
|
67
|
+
# 大余小余に合わせて減算する(折り返す)
|
68
|
+
#
|
69
|
+
# @param [Cycle::LunarRemainder] limit 上限
|
70
|
+
#
|
71
|
+
def decrease(limit:)
|
72
|
+
return if remainder < limit
|
73
|
+
|
74
|
+
remainder.sub!(limit)
|
75
|
+
end
|
73
76
|
end
|
74
77
|
end
|
75
78
|
end
|