zakuro 0.7.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -13
- data/VERSION +1 -1
- data/doc/dropped_date.md +93 -0
- data/doc/error.md +45 -0
- data/doc/operation/csv/month.csv +100 -79
- data/doc/operation/operation.xlsx +0 -0
- data/lib/zakuro/calculation/base/day.rb +52 -0
- data/lib/zakuro/calculation/base/gengou.rb +5 -5
- data/lib/zakuro/calculation/base/linear_gengou.rb +5 -5
- data/lib/zakuro/calculation/base/operated_year.rb +26 -24
- data/lib/zakuro/calculation/base/year.rb +7 -7
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +55 -47
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +28 -24
- data/lib/zakuro/calculation/cycle/zodiac.rb +22 -20
- data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +38 -29
- data/lib/zakuro/calculation/era/gengou/internal/connector.rb +4 -4
- data/lib/zakuro/calculation/era/gengou/internal/counter.rb +16 -16
- data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +74 -72
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +16 -16
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +58 -35
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +3 -3
- data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +111 -113
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +6 -6
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +7 -9
- data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +22 -20
- data/lib/zakuro/calculation/era/version/internal/crawler.rb +39 -22
- data/lib/zakuro/calculation/era/version/version.rb +12 -10
- data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +13 -9
- data/lib/zakuro/calculation/monthly/const.rb +18 -0
- data/lib/zakuro/calculation/monthly/initialized_month.rb +40 -38
- data/lib/zakuro/calculation/monthly/month.rb +17 -17
- data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
- data/lib/zakuro/calculation/monthly/operated_month.rb +37 -86
- data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
- data/lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb +44 -0
- data/lib/zakuro/calculation/option/dropped_date/location.rb +135 -0
- data/lib/zakuro/calculation/range/abstract_full_range.rb +40 -25
- data/lib/zakuro/calculation/range/abstract_operation_range.rb +111 -109
- data/lib/zakuro/calculation/range/dated_full_range.rb +1 -1
- data/lib/zakuro/calculation/range/dated_operation_range.rb +1 -1
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
- data/lib/zakuro/calculation/range/named_full_range.rb +1 -1
- data/lib/zakuro/calculation/range/named_operation_range.rb +1 -1
- data/lib/zakuro/calculation/range/operated_solar_term.rb +220 -0
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +32 -29
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +115 -117
- data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +1 -1
- data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +48 -46
- data/lib/zakuro/calculation/stella/solar/abstract_average.rb +31 -26
- data/lib/zakuro/calculation/stella/solar/abstract_location.rb +7 -5
- data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
- data/lib/zakuro/calculation/summary/internal/day.rb +42 -0
- data/lib/zakuro/calculation/summary/internal/month.rb +32 -11
- data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
- data/lib/zakuro/calculation/summary/internal/option.rb +101 -0
- data/lib/zakuro/calculation/summary/japan/range.rb +145 -118
- data/lib/zakuro/calculation/summary/japan/single.rb +87 -87
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +57 -50
- data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
- data/lib/zakuro/calculation/summary/western/range.rb +95 -92
- data/lib/zakuro/calculation/summary/western/single.rb +78 -76
- data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +123 -119
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +63 -56
- data/lib/zakuro/calculation/type/old_float.rb +2 -2
- data/lib/zakuro/calculation/type/optional.rb +46 -0
- data/lib/zakuro/condition.rb +142 -92
- data/lib/zakuro/context/context.rb +44 -0
- data/lib/zakuro/context/option.rb +119 -0
- data/lib/zakuro/context/version_class_resolver.rb +112 -0
- data/lib/zakuro/era/japan/calendar.rb +35 -33
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +8 -4
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +117 -118
- data/lib/zakuro/era/japan/gengou/alignment/line.rb +7 -5
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +20 -14
- data/lib/zakuro/era/japan/gengou/alignment.rb +27 -25
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +51 -34
- data/lib/zakuro/era/japan/gengou/resource/type.rb +45 -37
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +34 -32
- data/lib/zakuro/era/japan/gengou.rb +28 -26
- data/lib/zakuro/era/japan/version.rb +18 -16
- data/lib/zakuro/era/western/calendar.rb +104 -88
- data/lib/zakuro/exception/case/pattern.rb +39 -3
- data/lib/zakuro/exception/case/preset.rb +2 -2
- data/lib/zakuro/exception/exception.rb +17 -15
- data/lib/zakuro/exception/zakuro_error.rb +19 -1
- data/lib/zakuro/gateway/locale/date.rb +2 -2
- data/lib/zakuro/gateway/locale/range.rb +3 -3
- data/lib/zakuro/gateway/range.rb +3 -3
- data/lib/zakuro/gateway/single.rb +14 -3
- data/lib/zakuro/merchant.rb +79 -9
- data/lib/zakuro/operation/month/parser.rb +252 -249
- data/lib/zakuro/operation/month/type.rb +17 -8
- data/lib/zakuro/operation/month/validator.rb +148 -144
- data/lib/zakuro/operation/operation.rb +38 -36
- data/lib/zakuro/operation/yaml/month.yaml +955 -281
- data/lib/zakuro/output/response.rb +107 -141
- data/lib/zakuro/result/data/option/abstract_option.rb +37 -0
- data/lib/zakuro/result/data/option/dropped_date/calculation.rb +47 -0
- data/lib/zakuro/result/data/option/dropped_date/option.rb +47 -0
- data/lib/zakuro/result/data/option/dropped_date/solar_term.rb +48 -0
- data/lib/zakuro/result/data/single_day.rb +9 -1
- data/lib/zakuro/result/operation/month/annotation.rb +2 -2
- data/lib/zakuro/result/operation/month/history.rb +2 -2
- data/lib/zakuro/result/operation/month.rb +31 -0
- data/lib/zakuro/result/operation.rb +39 -0
- data/lib/zakuro/result/result.rb +3 -3
- data/lib/zakuro/tools/stringifier.rb +67 -42
- data/lib/zakuro/tools/typeconv.rb +17 -15
- data/lib/zakuro/tools/typeof.rb +15 -13
- data/lib/zakuro/version/daien/cycle/remainder.rb +2 -2
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
- data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -37
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -47
- data/lib/zakuro/version/daien/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +22 -20
- data/lib/zakuro/version/daien/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/daien/stella/solar/average.rb +53 -51
- data/lib/zakuro/version/daien/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/daien/stella/solar/value.rb +13 -11
- data/lib/zakuro/version/genka/cycle/remainder.rb +4 -4
- data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
- data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/genka/range/annual_range.rb +48 -44
- data/lib/zakuro/version/genka/stella/origin/first_term.rb +30 -28
- data/lib/zakuro/version/genka/stella/origin/january.rb +22 -20
- data/lib/zakuro/version/gihou/cycle/remainder.rb +2 -2
- data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +9 -9
- data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -37
- data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -47
- data/lib/zakuro/version/gihou/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +24 -22
- data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/gihou/stella/solar/average.rb +52 -50
- data/lib/zakuro/version/gihou/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/gihou/stella/solar/value.rb +13 -11
- data/lib/zakuro/version/senmyou/const/remainder.rb +7 -1
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +37 -2
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +10 -10
- data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +33 -0
- data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -36
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -34
- data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +22 -20
- data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +52 -50
- data/lib/zakuro/version/senmyou/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/senmyou/stella/solar/value.rb +13 -11
- metadata +27 -7
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -218
- data/lib/zakuro/result/operation/month/bundle.rb +0 -36
- data/lib/zakuro/result/operation/operation.rb +0 -44
- data/lib/zakuro/version/context.rb +0 -44
- data/lib/zakuro/version/version_class_resolver.rb +0 -74
@@ -22,26 +22,28 @@ module Zakuro
|
|
22
22
|
# @return [Float] 19年=235朔望月
|
23
23
|
METONIC_CYCLE = 235 / 19.to_f
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
25
|
+
class << self
|
26
|
+
#
|
27
|
+
# 1月経朔を求める
|
28
|
+
#
|
29
|
+
# @param [Integer] western_year 西暦年
|
30
|
+
#
|
31
|
+
# @return [Remainder] 11月経朔
|
32
|
+
#
|
33
|
+
def get(western_year:)
|
34
|
+
# (1612 + x) * 235 / 19 = A ...余り
|
35
|
+
stack = ((WESTERN_YEAR + western_year) * METONIC_CYCLE).to_i
|
36
|
+
# A * 22207 / 752 = B ...余りが朔の小余
|
37
|
+
minute_total = (stack * SYNODIC_MONTH / DAY).to_i
|
38
|
+
minute = (stack * SYNODIC_MONTH % DAY).to_i
|
39
|
+
# B / 60 = C ...余りが朔の大余
|
40
|
+
day = minute_total % Cycle::Remainder::LIMIT
|
41
|
+
# p stack
|
42
|
+
# p minute_total
|
43
|
+
# p minute
|
44
|
+
# p day
|
45
|
+
Cycle::Remainder.new(day: day, minute: minute, second: 0)
|
46
|
+
end
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -26,7 +26,7 @@ module Zakuro
|
|
26
26
|
# @param [Integer] total 繰り上げなしの小余
|
27
27
|
#
|
28
28
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
29
|
-
super(base_day: Const::Number::Cycle::DAY,
|
29
|
+
super(base_day: Const::Number::Cycle::DAY, base_minute: MINUTE,
|
30
30
|
day: day, minute: minute, second: second, total: total)
|
31
31
|
end
|
32
32
|
|
@@ -60,7 +60,7 @@ module Zakuro
|
|
60
60
|
# @param [Integer] total 繰り上げなしの小余
|
61
61
|
#
|
62
62
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
63
|
-
super(base_day: Const::Number::Cycle::DAY,
|
63
|
+
super(base_day: Const::Number::Cycle::DAY, base_minute: MINUTE,
|
64
64
|
day: day, minute: minute, second: second, total: total)
|
65
65
|
end
|
66
66
|
|
@@ -35,7 +35,7 @@ module Zakuro
|
|
35
35
|
lunar_age = Origin::LunarAge.get(western_year: western_year)
|
36
36
|
|
37
37
|
super(
|
38
|
-
|
38
|
+
quarter: QUARTER,
|
39
39
|
average_remainder: Origin::AverageNovember.get(western_year: western_year),
|
40
40
|
solar_location: Solar::Location.new(lunar_age: lunar_age),
|
41
41
|
lunar_location: Lunar::Location.new(
|
@@ -55,10 +55,10 @@ module Zakuro
|
|
55
55
|
# @return [Remainder] 定朔
|
56
56
|
#
|
57
57
|
def current_remainder
|
58
|
-
# debug("
|
58
|
+
# debug("average_remainder.format: #{average_remainder.format(form: '%d-%d-%.5f')}")
|
59
59
|
|
60
60
|
sum = correction_value
|
61
|
-
adjusted =
|
61
|
+
adjusted = average_remainder.add(
|
62
62
|
Cycle::Remainder.new(day: 0, minute: sum, second: 0)
|
63
63
|
)
|
64
64
|
# NOTE: 儀鳳暦では進朔しない
|
@@ -75,11 +75,11 @@ module Zakuro
|
|
75
75
|
# @return [Integer] 太陽運動の補正値
|
76
76
|
#
|
77
77
|
def correction_solar_value
|
78
|
-
|
79
|
-
# debug("
|
80
|
-
# debug("
|
78
|
+
solar_location.run
|
79
|
+
# debug("solar_term.remainder: #{solar_location.remainder.format(form: '%d-%d-%.5f')}")
|
80
|
+
# debug("solar_term.index: #{solar_location.index}")
|
81
81
|
|
82
|
-
Solar::Value.get(solar_location:
|
82
|
+
Solar::Value.get(solar_location: solar_location)
|
83
83
|
end
|
84
84
|
|
85
85
|
# :reek:TooManyStatements { max_statements: 6 }
|
@@ -90,9 +90,9 @@ module Zakuro
|
|
90
90
|
# @return [Integer] 月運動の補正値
|
91
91
|
#
|
92
92
|
def correction_moon_value
|
93
|
-
|
93
|
+
lunar_location.run
|
94
94
|
|
95
|
-
remainder =
|
95
|
+
remainder = lunar_location.adjusted_remainder
|
96
96
|
|
97
97
|
# debug("[lunar]remainder.format: #{remainder.format(form: '%d-%d-%.5f')}")
|
98
98
|
# debug("[lunar]remainder.day: #{remainder.day}")
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../calculation/option/dropped_date/abstract_parameter'
|
4
|
+
|
5
|
+
require_relative '../../const/number'
|
6
|
+
require_relative '../../const/remainder'
|
7
|
+
require_relative '../../cycle/remainder'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
# :nodoc:
|
12
|
+
module Gihou
|
13
|
+
# :nodoc:
|
14
|
+
module Option
|
15
|
+
# :nodoc:
|
16
|
+
module DroppedDate
|
17
|
+
#
|
18
|
+
# Parameter 引数
|
19
|
+
#
|
20
|
+
class Parameter < Calculation::Option::DroppedDate::AbstractParameter
|
21
|
+
#
|
22
|
+
# 初期化
|
23
|
+
#
|
24
|
+
def initialize
|
25
|
+
super(valid: false)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -14,24 +14,26 @@ module Zakuro
|
|
14
14
|
# AnnualRange 年間範囲
|
15
15
|
#
|
16
16
|
module AnnualRange
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
17
|
+
class << self
|
18
|
+
#
|
19
|
+
# 一覧取得する
|
20
|
+
#
|
21
|
+
# * 対象年に対して、前年11月-当年11月までを出力する
|
22
|
+
# * 対象年(西暦)と計算年(元号x年)の紐付けは行わない
|
23
|
+
#
|
24
|
+
# @param [Context::Context] context 暦コンテキスト
|
25
|
+
# @param [Integer] western_year 西暦年
|
26
|
+
#
|
27
|
+
# @return [Array<Month>] 1年データ
|
28
|
+
#
|
29
|
+
def get(context:, western_year:)
|
30
|
+
lunar_phase = Monthly::LunarPhase.new(western_year: western_year)
|
31
|
+
solar_average = Solar::Average.new(western_year: western_year)
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
Calculation::Range::MedievalAnnualRange.get(
|
34
|
+
context: context, lunar_phase: lunar_phase, solar_average: solar_average
|
35
|
+
)
|
36
|
+
end
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
@@ -72,9 +72,10 @@ module Zakuro
|
|
72
72
|
# @return [False] 不一致
|
73
73
|
#
|
74
74
|
def match?(day:, minute:)
|
75
|
-
|
75
|
+
inner_day = @day
|
76
|
+
return false unless inner_day == day
|
76
77
|
|
77
|
-
return false unless
|
78
|
+
return false unless range.include?(minute: minute)
|
78
79
|
|
79
80
|
true
|
80
81
|
end
|
@@ -85,7 +86,7 @@ module Zakuro
|
|
85
86
|
# @return [Integer] 分母
|
86
87
|
#
|
87
88
|
def denominator
|
88
|
-
|
89
|
+
range.denominator
|
89
90
|
end
|
90
91
|
end
|
91
92
|
|
@@ -123,7 +124,7 @@ module Zakuro
|
|
123
124
|
# @return [False] 含まれない
|
124
125
|
#
|
125
126
|
def include?(minute:)
|
126
|
-
minute >=
|
127
|
+
minute >= min && minute <= max
|
127
128
|
end
|
128
129
|
|
129
130
|
#
|
@@ -132,7 +133,7 @@ module Zakuro
|
|
132
133
|
# @return [Integer] 分母
|
133
134
|
#
|
134
135
|
def denominator
|
135
|
-
|
136
|
+
max - min
|
136
137
|
end
|
137
138
|
end
|
138
139
|
|
@@ -162,7 +163,7 @@ module Zakuro
|
|
162
163
|
# @return [String] 文字
|
163
164
|
#
|
164
165
|
def to_s
|
165
|
-
"per:#{
|
166
|
+
"per:#{per}, stack:#{stack}"
|
166
167
|
end
|
167
168
|
end
|
168
169
|
|
@@ -207,42 +208,46 @@ module Zakuro
|
|
207
208
|
].freeze
|
208
209
|
# rubocop:enable Layout/LineLength
|
209
210
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
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
|
224
228
|
|
225
|
-
|
226
|
-
|
229
|
+
raise ArgumentError.new, "invalid parameter: #{day}/#{minute}"
|
230
|
+
end
|
227
231
|
|
228
|
-
|
232
|
+
# :reek:ControlParameter
|
229
233
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
234
|
+
#
|
235
|
+
# 小余の下げ幅を求める
|
236
|
+
#
|
237
|
+
# @param [Integer] day 大余
|
238
|
+
# @param [Integer] minute 小余
|
239
|
+
#
|
240
|
+
# @return [Integer] 小余の下げ幅
|
241
|
+
#
|
242
|
+
def minus_minute(day:, minute:)
|
243
|
+
limit = DAY_LIMIT.fetch(day, -1)
|
244
|
+
# 該当なし
|
245
|
+
return minute if limit == -1
|
242
246
|
|
243
|
-
|
247
|
+
return minute unless minute > limit
|
244
248
|
|
245
|
-
|
249
|
+
minute - limit
|
250
|
+
end
|
246
251
|
end
|
247
252
|
end
|
248
253
|
end
|
@@ -21,22 +21,24 @@ module Zakuro
|
|
21
21
|
# @return [Integer] 年
|
22
22
|
YEAR = Const::Number::Cycle::YEAR
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
class << self
|
25
|
+
#
|
26
|
+
# 対象年の最初の入暦を求める
|
27
|
+
#
|
28
|
+
# @param [Remainder] lunar_age 天正閏余
|
29
|
+
# @param [Integer] western_year 西暦年
|
30
|
+
#
|
31
|
+
# @return [Cycle::LunarRemainder] 入暦
|
32
|
+
#
|
33
|
+
def first_remainder(lunar_age:, western_year:)
|
34
|
+
# 積年の開始から対象年までの年数
|
35
|
+
total_year = TOTAL_YEAR + western_year - BEGIN_YEAR
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
# 通積分 - 天正閏余
|
38
|
+
total_day = total_year * YEAR - lunar_age.to_minute
|
38
39
|
|
39
|
-
|
40
|
+
Cycle::LunarRemainder.new(total: (total_day % ANOMALISTIC_MONTH))
|
41
|
+
end
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
@@ -21,54 +21,59 @@ module Zakuro
|
|
21
21
|
|
22
22
|
# :reek:TooManyStatements { max_statements: 9 }
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
return
|
68
|
-
|
69
|
-
raise ArgumentError
|
24
|
+
class << self
|
25
|
+
#
|
26
|
+
# 月の運行による補正値を算出する
|
27
|
+
#
|
28
|
+
# @param [Cycle::LunarRemainder] remainder 月の大余小余
|
29
|
+
#
|
30
|
+
# @return [Integer] 補正値
|
31
|
+
#
|
32
|
+
def get(remainder:)
|
33
|
+
valid?(remainder: remainder)
|
34
|
+
|
35
|
+
day, minute = Calculation::Lunar::ChoukeiValue.remainder_without_second(
|
36
|
+
remainder: remainder
|
37
|
+
)
|
38
|
+
|
39
|
+
# 引き当て
|
40
|
+
row = Adjustment.specify(day: day, minute: minute)
|
41
|
+
|
42
|
+
value = row.value
|
43
|
+
|
44
|
+
# LOGGER.debug("value.per: #{value.per}")
|
45
|
+
# LOGGER.debug("row.denominator: #{row.denominator}")
|
46
|
+
# LOGGER.debug("value.stack: #{value.stack}")
|
47
|
+
|
48
|
+
minus_minute = Adjustment.minus_minute(day: day, minute: minute)
|
49
|
+
|
50
|
+
day = Calculation::Lunar::ChoukeiValue.rounded_day(
|
51
|
+
per: value.per, denominator: row.denominator, minute: minus_minute
|
52
|
+
)
|
53
|
+
|
54
|
+
# LOGGER.debug("day: #{day}")
|
55
|
+
|
56
|
+
value.stack + day
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
#
|
62
|
+
# 大余小余を検証する
|
63
|
+
#
|
64
|
+
# @param [Cycle::LunarRemainder] remainder 大余小余
|
65
|
+
#
|
66
|
+
# @return [True] 正しい(月の位相計算に使う大余小余)
|
67
|
+
# @return [True] 正しくない
|
68
|
+
#
|
69
|
+
# @raise [ArgumentError] 引数エラー
|
70
|
+
#
|
71
|
+
def valid?(remainder:)
|
72
|
+
return if remainder.is_a?(Cycle::LunarRemainder)
|
73
|
+
|
74
|
+
raise ArgumentError, "unmatch parameter type: #{remainder.class}"
|
75
|
+
end
|
70
76
|
end
|
71
|
-
private_class_method :valid?
|
72
77
|
end
|
73
78
|
end
|
74
79
|
end
|
@@ -13,20 +13,22 @@ module Zakuro
|
|
13
13
|
# AverageNovember 11月経
|
14
14
|
#
|
15
15
|
module AverageNovember
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
16
|
+
class << self
|
17
|
+
#
|
18
|
+
# 11月経朔(冬至が含まれる月の1日)を求める
|
19
|
+
#
|
20
|
+
# @param [Integer] western_year 西暦年
|
21
|
+
#
|
22
|
+
# @return [Remainder] 11月経朔
|
23
|
+
#
|
24
|
+
def get(western_year:)
|
25
|
+
# 冬至
|
26
|
+
winter_solstice = WinterSolstice.get(western_year: western_year)
|
27
|
+
# 天正閏余
|
28
|
+
lunar_age = LunarAge.get(western_year: western_year)
|
28
29
|
|
29
|
-
|
30
|
+
winter_solstice.sub(lunar_age)
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -28,33 +28,35 @@ module Zakuro
|
|
28
28
|
|
29
29
|
# :reek:TooManyStatements { max_statements: 7 }
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
31
|
+
class << self
|
32
|
+
#
|
33
|
+
# 対象年の天正閏余(冬至より前にある11月経朔との差 = 月齢)を算出する
|
34
|
+
# 太陽と月の運動による補正値を算出し、その補正結果を返す
|
35
|
+
#
|
36
|
+
# @param [Integer] western_year 西暦年
|
37
|
+
#
|
38
|
+
# @return [Remainder] 天正閏余
|
39
|
+
#
|
40
|
+
def get(western_year:)
|
41
|
+
# 積年の開始から対象年までの年数
|
42
|
+
total = TOTAL_YEAR + western_year - BEGIN_YEAR
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
# 12朔望月に対する1年の余り(単位:分)
|
45
|
+
remainder_minute = YEAR - (SYNODIC_MONTH * 12)
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
# 朔望月に含まれなかった余り(単位:年)
|
48
|
+
remainder_year = total % SYNODIC_MONTH
|
48
49
|
|
49
|
-
|
50
|
+
LOGGER.debug("[01]: #{remainder_year}")
|
50
51
|
|
51
|
-
|
52
|
-
|
52
|
+
# 天正閏余
|
53
|
+
lunar_age = remainder_minute * remainder_year % SYNODIC_MONTH
|
53
54
|
|
54
|
-
|
55
|
+
LOGGER.debug("[02]: #{lunar_age}")
|
55
56
|
|
56
|
-
|
57
|
-
|
57
|
+
# 大余・小余に変換する
|
58
|
+
Cycle::Remainder.new(total: lunar_age)
|
59
|
+
end
|
58
60
|
end
|
59
61
|
end
|
60
62
|
end
|
@@ -26,28 +26,30 @@ module Zakuro
|
|
26
26
|
# @return [Output::Logger] ロガー
|
27
27
|
LOGGER = Output::Logger.new(location: 'winter_solstice')
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
29
|
+
class << self
|
30
|
+
# :reek:TooManyStatements { max_statements: 6 }
|
31
|
+
|
32
|
+
#
|
33
|
+
# 対象年の前年の冬至を求める
|
34
|
+
#
|
35
|
+
# @param [Integer] western_year 西暦年
|
36
|
+
#
|
37
|
+
# @return [Remainder] 前年の冬至
|
38
|
+
#
|
39
|
+
def get(western_year:)
|
40
|
+
# 積年の開始から対象年までの年数
|
41
|
+
total = TOTAL_YEAR + western_year - BEGIN_YEAR
|
42
|
+
remainder_year = total % SIXTY_DAYS
|
43
|
+
|
44
|
+
LOGGER.debug("[01]:#{remainder_year}")
|
45
|
+
|
46
|
+
# 通余を使う
|
47
|
+
winter_solstice_minute = (remainder_year * REMAINDER_ALL_YEAR) % SIXTY_DAYS
|
48
|
+
|
49
|
+
LOGGER.debug("[02]:#{winter_solstice_minute}")
|
50
|
+
|
51
|
+
Cycle::Remainder.new(total: winter_solstice_minute)
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
@@ -76,16 +76,18 @@ module Zakuro
|
|
76
76
|
taisetsu: Row.new(stack: -54.0, per_term: +3.4091, per_day: +0.0372) # 大雪(たいせつ)
|
77
77
|
}.freeze
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
79
|
+
class << self
|
80
|
+
#
|
81
|
+
# 24気損益眺朒(ちょうじく)数の行データを特定する
|
82
|
+
#
|
83
|
+
# @param [Integer] index 連番(二十四節気)
|
84
|
+
#
|
85
|
+
# @return [Row] 行データ
|
86
|
+
#
|
87
|
+
def specify(index:)
|
88
|
+
key = Cycle::SolarTerm::ORDER[index]
|
89
|
+
Adjustment::MAP[key].clone
|
90
|
+
end
|
89
91
|
end
|
90
92
|
end
|
91
93
|
end
|