zakuro 0.7.2 → 0.8.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 +3 -3
- data/VERSION +1 -1
- 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 +23 -21
- data/lib/zakuro/calculation/base/year.rb +3 -3
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +50 -44
- 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 +39 -37
- data/lib/zakuro/calculation/monthly/month.rb +15 -15
- data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
- data/lib/zakuro/calculation/monthly/operated_month.rb +36 -85
- data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
- data/lib/zakuro/calculation/range/abstract_full_range.rb +34 -21
- data/lib/zakuro/calculation/range/abstract_operation_range.rb +109 -107
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
- 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 +5 -5
- data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
- data/lib/zakuro/calculation/summary/internal/day.rb +21 -19
- data/lib/zakuro/calculation/summary/internal/month.rb +25 -12
- data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
- data/lib/zakuro/calculation/summary/internal/option.rb +66 -50
- data/lib/zakuro/calculation/summary/japan/range.rb +145 -124
- data/lib/zakuro/calculation/summary/japan/single.rb +87 -87
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +54 -52
- 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 -124
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +60 -58
- data/lib/zakuro/calculation/type/old_float.rb +2 -2
- data/lib/zakuro/condition.rb +121 -111
- data/lib/zakuro/context/context.rb +1 -1
- data/lib/zakuro/context/option.rb +31 -29
- data/lib/zakuro/context/version_class_resolver.rb +26 -24
- data/lib/zakuro/era/japan/calendar.rb +35 -33
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +4 -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 -36
- data/lib/zakuro/era/japan/gengou/resource/type.rb +39 -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 +102 -90
- data/lib/zakuro/exception/case/preset.rb +2 -2
- data/lib/zakuro/exception/exception.rb +15 -13
- data/lib/zakuro/exception/zakuro_error.rb +1 -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 +1 -1
- data/lib/zakuro/gateway/single.rb +13 -2
- data/lib/zakuro/merchant.rb +1 -1
- data/lib/zakuro/operation/month/parser.rb +252 -251
- 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/output/response.rb +112 -113
- 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 +66 -64
- data/lib/zakuro/tools/typeconv.rb +17 -15
- data/lib/zakuro/tools/typeof.rb +15 -13
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
- data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -39
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -49
- 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 +2 -2
- data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
- 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/monthly/lunar_phase.rb +9 -9
- data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -39
- data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -49
- 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/monthly/lunar_phase.rb +10 -10
- data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -38
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -36
- 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 +12 -9
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -218
- data/lib/zakuro/result/operation/bundle.rb +0 -44
- data/lib/zakuro/result/operation/month/bundle.rb +0 -36
@@ -14,39 +14,42 @@ module Zakuro
|
|
14
14
|
# GengouScroller 元号スクロール
|
15
15
|
#
|
16
16
|
module GengouScroller
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
years
|
25
|
-
|
17
|
+
class << self
|
18
|
+
#
|
19
|
+
# 元号を年に設定する
|
20
|
+
#
|
21
|
+
# @param [Gengou::Scroll] scroll 元号スクロール
|
22
|
+
# @param [Array<Base::Year>] years 年
|
23
|
+
#
|
24
|
+
def set(scroll:, years: [])
|
25
|
+
years.each do |year|
|
26
|
+
update_gengou_year(scroll: scroll, year: year)
|
27
|
+
end
|
26
28
|
end
|
27
|
-
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
30
|
+
private
|
31
|
+
|
32
|
+
#
|
33
|
+
# 年の元号を更新する
|
34
|
+
#
|
35
|
+
# @param [Base::Year] year 年
|
36
|
+
#
|
37
|
+
def update_gengou_year(scroll:, year:)
|
38
|
+
year.months.each_with_index do |month, index|
|
39
|
+
scroll.run(month: month)
|
40
|
+
gengou = scroll.to_gengou
|
41
|
+
year.months[index] = Monthly::Month.new(
|
42
|
+
context: month.context,
|
43
|
+
month_label: month.month_label,
|
44
|
+
first_day: Monthly::FirstDay.new(
|
45
|
+
remainder: month.first_day.remainder,
|
46
|
+
western_date: gengou.start_date.clone
|
47
|
+
),
|
48
|
+
solar_terms: month.solar_terms, gengou: gengou
|
49
|
+
)
|
50
|
+
end
|
47
51
|
end
|
48
52
|
end
|
49
|
-
private_class_method :update_gengou_year
|
50
53
|
end
|
51
54
|
end
|
52
55
|
end
|
@@ -16,133 +16,131 @@ module Zakuro
|
|
16
16
|
# YearBoundary 年境界
|
17
17
|
#
|
18
18
|
module YearBoundary
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
19
|
+
class << self
|
20
|
+
#
|
21
|
+
# 年間範囲内の年データの開始月を変更する
|
22
|
+
#
|
23
|
+
# @param [Context::Context] context 暦コンテキスト
|
24
|
+
# @param [Array<Base::Year>] annual_ranges 年データ(冬至基準)
|
25
|
+
#
|
26
|
+
# @return [Array<Base::Year>] 年データ(元旦基準)
|
27
|
+
#
|
28
|
+
def get(context:, annual_ranges:)
|
29
|
+
categorize(context: context, annual_ranges: annual_ranges)
|
30
|
+
rearranged_years(context: context, annual_ranges: annual_ranges)
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
33
|
+
private
|
34
|
+
|
35
|
+
#
|
36
|
+
# 年間範囲内の年データの開始月を変更する
|
37
|
+
#
|
38
|
+
# @param [Context::Context] context 暦コンテキスト
|
39
|
+
# @param [Array<Base::Year>] annual_ranges 年データ(冬至基準)
|
40
|
+
#
|
41
|
+
# @return [Array<Base::Year>] 年データ(元旦基準)
|
42
|
+
#
|
43
|
+
def rearranged_years(context:, annual_ranges:)
|
44
|
+
years = []
|
45
|
+
|
46
|
+
(0..(annual_ranges.size - 2)).each do |index|
|
47
|
+
year = rearranged_year(
|
48
|
+
context: context, annual_ranges: annual_ranges, index: index
|
49
|
+
)
|
50
|
+
years.push(year)
|
51
|
+
end
|
52
|
+
|
53
|
+
years
|
48
54
|
end
|
49
55
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
def self.categorize(context:, annual_ranges:)
|
61
|
-
annual_ranges.each do |annual_range|
|
62
|
-
categorize_year(context: context, annual_range: annual_range)
|
56
|
+
#
|
57
|
+
# 年間範囲を昨年/今年で分類する
|
58
|
+
#
|
59
|
+
# @param [Context::Context] context 暦コンテキスト
|
60
|
+
# @param [Array<Base::Year>] annual_range 1年データ
|
61
|
+
#
|
62
|
+
def categorize(context:, annual_ranges:)
|
63
|
+
annual_ranges.each do |annual_range|
|
64
|
+
categorize_year(context: context, annual_range: annual_range)
|
65
|
+
end
|
63
66
|
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
)
|
67
|
+
|
68
|
+
#
|
69
|
+
# 各月を昨年/今年で分類する
|
70
|
+
#
|
71
|
+
# @param [Context::Context] context 暦コンテキスト
|
72
|
+
# @param [Array<Month>] annual_range 1年データ
|
73
|
+
#
|
74
|
+
def categorize_year(context:, annual_range:)
|
75
|
+
is_last_year = true
|
76
|
+
annual_range.each_with_index do |month, index|
|
77
|
+
is_last_year = false if month.number == 1
|
78
|
+
|
79
|
+
annual_range[index] = Monthly::InitializedMonth.new(
|
80
|
+
context: context,
|
81
|
+
month_label: month.month_label, first_day: month.first_day,
|
82
|
+
solar_terms: month.solar_terms, phase_index: month.phase_index,
|
83
|
+
is_last_year: is_last_year
|
84
|
+
)
|
85
|
+
end
|
84
86
|
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
year
|
105
|
-
end
|
106
|
-
private_class_method :rearranged_year
|
107
|
-
|
108
|
-
#
|
109
|
-
# 当年データを生成する
|
110
|
-
#
|
111
|
-
# @param [Context::Context] context 暦コンテキスト
|
112
|
-
# @param [Array<Month>] annual_range 1年データ
|
113
|
-
#
|
114
|
-
# @return [Base::Year] 当年月ありの対象年
|
115
|
-
#
|
116
|
-
def self.push_current_year(context:, annual_range:)
|
117
|
-
year = Base::Year.new(context: context)
|
118
|
-
annual_range.each do |month|
|
119
|
-
next if month.is_last_year
|
120
|
-
|
121
|
-
year.push(month: month)
|
87
|
+
|
88
|
+
#
|
89
|
+
# 年データの開始月を変更する
|
90
|
+
#
|
91
|
+
# @param [Context::Context] context 暦コンテキスト
|
92
|
+
# @param [Array<Base::Year>] annual_ranges 年データ(冬至基準)
|
93
|
+
# @param [Integer] index 対象年の要素番号
|
94
|
+
#
|
95
|
+
# @return [Base::Year] 年データ(元旦基準)
|
96
|
+
#
|
97
|
+
def rearranged_year(context:, annual_ranges:, index:)
|
98
|
+
current_annual_range = annual_ranges[index]
|
99
|
+
next_annual_range = annual_ranges[index + 1]
|
100
|
+
|
101
|
+
year = push_current_year(context: context, annual_range: current_annual_range)
|
102
|
+
push_last_year(annual_range: next_annual_range, year: year)
|
103
|
+
|
104
|
+
year
|
122
105
|
end
|
123
106
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
year
|
107
|
+
#
|
108
|
+
# 当年データを生成する
|
109
|
+
#
|
110
|
+
# @param [Context::Context] context 暦コンテキスト
|
111
|
+
# @param [Array<Month>] annual_range 1年データ
|
112
|
+
#
|
113
|
+
# @return [Base::Year] 当年月ありの対象年
|
114
|
+
#
|
115
|
+
def push_current_year(context:, annual_range:)
|
116
|
+
year = Base::Year.new(context: context)
|
117
|
+
annual_range.each do |month|
|
118
|
+
next if month.is_last_year
|
119
|
+
|
120
|
+
year.push(month: month)
|
121
|
+
end
|
122
|
+
|
123
|
+
year
|
141
124
|
end
|
142
125
|
|
143
|
-
|
126
|
+
#
|
127
|
+
# 昨年データを生成する
|
128
|
+
#
|
129
|
+
# @param [Array<Month>] annual_range 1年データ
|
130
|
+
# @param [Base::Year] year 対象年
|
131
|
+
#
|
132
|
+
# @return [Base::Year] 昨年月ありの対象年
|
133
|
+
#
|
134
|
+
def push_last_year(annual_range:, year: Base::Year.new)
|
135
|
+
annual_range.each do |month|
|
136
|
+
next unless month.is_last_year
|
137
|
+
|
138
|
+
year.push(month: month)
|
139
|
+
end
|
140
|
+
|
141
|
+
year
|
142
|
+
end
|
144
143
|
end
|
145
|
-
private_class_method :push_last_year
|
146
144
|
end
|
147
145
|
end
|
148
146
|
end
|
@@ -52,7 +52,7 @@ module Zakuro
|
|
52
52
|
# @return [Cycle::AbstractRemainder] 1始まりの大余小余
|
53
53
|
#
|
54
54
|
def adjusted_remainder
|
55
|
-
|
55
|
+
remainder.add(Cycle::AbstractRemainder.new(day: 1, minute: 0, second: 0))
|
56
56
|
end
|
57
57
|
|
58
58
|
private
|
@@ -12,59 +12,61 @@ module Zakuro
|
|
12
12
|
# ChoukeiValue 再考長慶宣明暦算法
|
13
13
|
#
|
14
14
|
module ChoukeiValue
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
15
|
+
class << self
|
16
|
+
#
|
17
|
+
# 四捨五入した大余を返す
|
18
|
+
#
|
19
|
+
# @param [Integer] per 増減率
|
20
|
+
# @param [Integer] denominator 小余の分母
|
21
|
+
# @param [Integer] minute 小余
|
22
|
+
#
|
23
|
+
# @return [Integer] 累計値(大余)
|
24
|
+
#
|
25
|
+
def rounded_day(per:, denominator:, minute:)
|
26
|
+
remainder_minute = Type::OldFloat.new((per * minute).to_f)
|
27
|
+
day = day_only(remainder_minute: remainder_minute.get, denominator: denominator)
|
28
|
+
# 繰り上げ結果を足す
|
29
|
+
day += carried_minute(remainder_minute: remainder_minute, denominator: denominator)
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
day
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
34
|
+
#
|
35
|
+
# 秒がない大余小余にする
|
36
|
+
#
|
37
|
+
# @param [Cycle::LunarRemainder] remainder 大余小余
|
38
|
+
#
|
39
|
+
# @note 815年で大余繰り上げあり
|
40
|
+
#
|
41
|
+
# @return [Integer] 大余
|
42
|
+
# @return [Float] 小余
|
43
|
+
#
|
44
|
+
def remainder_without_second(remainder:)
|
45
|
+
adjusted = remainder.class.new(
|
46
|
+
day: remainder.day, minute: remainder.floor_minute, second: 0
|
47
|
+
)
|
48
|
+
adjusted.carry!
|
48
49
|
|
49
|
-
|
50
|
-
|
50
|
+
[adjusted.day, adjusted.minute]
|
51
|
+
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
private
|
54
|
+
|
55
|
+
def day_only(remainder_minute:, denominator:)
|
56
|
+
float_day = Type::OldFloat.new(remainder_minute / denominator)
|
57
|
+
# 切り捨て(プラスマイナスに関わらず小数点以下切り捨て)
|
58
|
+
float_day.floor!
|
59
|
+
float_day.get
|
60
|
+
end
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
def carried_minute(remainder_minute:, denominator:)
|
63
|
+
remainder_day = remainder_minute.abs % denominator
|
64
|
+
# 四捨五入(1/2日 以上なら繰り上げる)
|
65
|
+
return remainder_minute.sign if remainder_day >= (denominator / 2)
|
64
66
|
|
65
|
-
|
67
|
+
0
|
68
|
+
end
|
66
69
|
end
|
67
|
-
private_class_method :carried_minute
|
68
70
|
end
|
69
71
|
end
|
70
72
|
end
|
@@ -10,6 +10,9 @@ module Zakuro
|
|
10
10
|
# AbstractAverage 平気(太陽軌道平均)
|
11
11
|
#
|
12
12
|
class AbstractAverage
|
13
|
+
# @return [Cycle::AbstractSolarTerm] 入定気
|
14
|
+
attr_reader :solar_term
|
15
|
+
|
13
16
|
#
|
14
17
|
# 初期化
|
15
18
|
#
|
@@ -41,30 +44,32 @@ module Zakuro
|
|
41
44
|
|
42
45
|
# :reek:TooManyStatements { max_statements: 7 }
|
43
46
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
47
|
+
class << self
|
48
|
+
#
|
49
|
+
# 月内(当月朔日から当月末日(来月朔日の前日)の間)に二十四節気があるか
|
50
|
+
# @note 大余60で一巡するため 以下2パターンがある
|
51
|
+
# * current_month <= next_month : (二十四節気) >= current_month && (二十四節気) < next_month
|
52
|
+
# * current_month > next_month : (二十四節気) >= current_month || (二十四節気) < next_month
|
53
|
+
#
|
54
|
+
# @param [Cycle::AbstractRemainder] solar_term 二十四節気
|
55
|
+
# @param [Cycle::AbstractRemainder] current_month 月初
|
56
|
+
# @param [Cycle::AbstractRemainder] next_month 月末
|
57
|
+
#
|
58
|
+
# @return [True] 対象の二十四節気がある
|
59
|
+
# @return [False] 対象の二十四節気がない
|
60
|
+
#
|
61
|
+
def in_solar_term?(solar_term:, current_month:, next_month:)
|
62
|
+
# 大余で比較する
|
63
|
+
target_time = solar_term.day
|
64
|
+
current_month_time = current_month.day
|
65
|
+
next_month_time = next_month.day
|
66
|
+
current_month_over = (target_time >= current_month_time)
|
67
|
+
next_month_under = (target_time < next_month_time)
|
64
68
|
|
65
|
-
|
69
|
+
return current_month_over && next_month_under if current_month_time <= next_month_time
|
66
70
|
|
67
|
-
|
71
|
+
current_month_over || next_month_under
|
72
|
+
end
|
68
73
|
end
|
69
74
|
|
70
75
|
private
|
@@ -83,8 +88,8 @@ module Zakuro
|
|
83
88
|
# * 閏月は1回しか設定しない
|
84
89
|
# * 最大2回設定する(中気・節気)
|
85
90
|
(0..3).each do |_index|
|
86
|
-
in_range =
|
87
|
-
solar_term:
|
91
|
+
in_range = self.class.in_solar_term?(
|
92
|
+
solar_term: solar_term.remainder, current_month: current_month.remainder,
|
88
93
|
next_month: next_month.remainder
|
89
94
|
)
|
90
95
|
|
@@ -97,7 +102,7 @@ module Zakuro
|
|
97
102
|
next
|
98
103
|
end
|
99
104
|
|
100
|
-
current_month.add_term(term:
|
105
|
+
current_month.add_term(term: solar_term.clone)
|
101
106
|
next_solar_term
|
102
107
|
|
103
108
|
# 定気は最大2つまで
|
@@ -109,7 +114,7 @@ module Zakuro
|
|
109
114
|
# 次の二十四節気に移る
|
110
115
|
#
|
111
116
|
def next_solar_term
|
112
|
-
|
117
|
+
solar_term.next_term!
|
113
118
|
end
|
114
119
|
end
|
115
120
|
end
|
@@ -58,7 +58,7 @@ module Zakuro
|
|
58
58
|
# 弦の分だけ太陽地点を進める
|
59
59
|
#
|
60
60
|
def add_quarter
|
61
|
-
|
61
|
+
remainder.add!(quarter)
|
62
62
|
end
|
63
63
|
|
64
64
|
#
|
@@ -151,12 +151,12 @@ module Zakuro
|
|
151
151
|
def prev(index:)
|
152
152
|
interval = interval(index: index)
|
153
153
|
if remainder > interval
|
154
|
-
|
154
|
+
remainder.sub!(interval)
|
155
155
|
return
|
156
156
|
end
|
157
157
|
|
158
158
|
# 入定気が確定する
|
159
|
-
@remainder = interval.sub(
|
159
|
+
@remainder = interval.sub(remainder)
|
160
160
|
@index = index
|
161
161
|
end
|
162
162
|
|
@@ -165,7 +165,7 @@ module Zakuro
|
|
165
165
|
#
|
166
166
|
def next_index
|
167
167
|
@index += 1
|
168
|
-
@index = 0 if
|
168
|
+
@index = 0 if index >= interval_size
|
169
169
|
end
|
170
170
|
|
171
171
|
#
|
@@ -176,7 +176,7 @@ module Zakuro
|
|
176
176
|
# 現在の二十四節気に留まる
|
177
177
|
return if remainder < interval
|
178
178
|
|
179
|
-
|
179
|
+
remainder.sub!(interval)
|
180
180
|
|
181
181
|
next_index
|
182
182
|
|