zakuro 0.1.0 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +30 -12
  3. data/doc/operation/csv/month.csv +202 -202
  4. data/doc/operation/operation.xlsx +0 -0
  5. data/doc/operation/transfer.rb +6 -2
  6. data/lib/zakuro/calculation/base/multi_gengou.rb +101 -0
  7. data/lib/zakuro/calculation/base/multi_gengou_roller.rb +218 -0
  8. data/lib/zakuro/calculation/base/year.rb +107 -0
  9. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +471 -0
  10. data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +173 -0
  11. data/lib/zakuro/calculation/cycle/zodiac.rb +106 -0
  12. data/lib/zakuro/calculation/monthly/first_day.rb +45 -0
  13. data/lib/zakuro/calculation/monthly/initialized_month.rb +125 -0
  14. data/lib/zakuro/calculation/monthly/month.rb +187 -0
  15. data/lib/zakuro/calculation/monthly/month_label.rb +88 -0
  16. data/lib/zakuro/calculation/monthly/operated_month.rb +209 -0
  17. data/lib/zakuro/calculation/range/full_range.rb +210 -0
  18. data/lib/zakuro/calculation/range/operated_range.rb +144 -0
  19. data/lib/zakuro/calculation/range/operated_solar_terms.rb +201 -0
  20. data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +82 -0
  21. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +146 -0
  22. data/lib/zakuro/calculation/specifier/single_day.rb +109 -0
  23. data/lib/zakuro/calculation/summary/single.rb +129 -0
  24. data/lib/zakuro/condition.rb +16 -13
  25. data/lib/zakuro/era/japan/gengou/parser.rb +1 -3
  26. data/lib/zakuro/era/japan/gengou/type.rb +3 -3
  27. data/lib/zakuro/era/japan/gengou/validator.rb +15 -13
  28. data/lib/zakuro/merchant.rb +2 -2
  29. data/lib/zakuro/operation/month/parser.rb +132 -36
  30. data/lib/zakuro/operation/month/type.rb +11 -10
  31. data/lib/zakuro/operation/month/validator.rb +332 -28
  32. data/lib/zakuro/operation/operation.rb +21 -0
  33. data/lib/zakuro/operation/yaml/month.yaml +1 -1
  34. data/lib/zakuro/output/error.rb +7 -6
  35. data/lib/zakuro/output/logger.rb +50 -49
  36. data/lib/zakuro/output/response.rb +145 -144
  37. data/lib/zakuro/result/operation.rb +64 -36
  38. data/lib/zakuro/tools/stringifier.rb +2 -2
  39. data/lib/zakuro/tools/typeof.rb +2 -2
  40. data/lib/zakuro/version.rb +1 -1
  41. data/lib/zakuro/version/abstract_version.rb +1 -1
  42. data/lib/zakuro/version/context.rb +23 -0
  43. data/lib/zakuro/version/senmyou/const/number.rb +51 -0
  44. data/lib/zakuro/version/senmyou/const/remainder.rb +43 -0
  45. data/lib/zakuro/version/senmyou/cycle/remainder.rb +61 -0
  46. data/lib/zakuro/version/senmyou/cycle/solar_term.rb +31 -0
  47. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +166 -181
  48. data/lib/zakuro/version/senmyou/range/annual_range.rb +86 -159
  49. data/lib/zakuro/version/senmyou/senmyou.rb +10 -4
  50. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +237 -0
  51. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +45 -0
  52. data/lib/zakuro/version/senmyou/stella/lunar/location.rb +108 -0
  53. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +89 -0
  54. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +34 -0
  55. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +62 -0
  56. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +55 -0
  57. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +93 -0
  58. data/lib/zakuro/version/senmyou/stella/solar/average.rb +175 -0
  59. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +103 -0
  60. data/lib/zakuro/version/senmyou/stella/solar/location.rb +164 -0
  61. data/lib/zakuro/version/senmyou/stella/solar/value.rb +138 -0
  62. data/lib/zakuro/version/version_class_resolver.rb +62 -0
  63. data/lib/zakuro/version_factory.rb +2 -2
  64. metadata +38 -24
  65. data/lib/zakuro/cycle/abstract_remainder.rb +0 -456
  66. data/lib/zakuro/cycle/zodiac.rb +0 -103
  67. data/lib/zakuro/version/senmyou/base/era.rb +0 -83
  68. data/lib/zakuro/version/senmyou/base/multi_gengou.rb +0 -98
  69. data/lib/zakuro/version/senmyou/base/multi_gengou_roller.rb +0 -217
  70. data/lib/zakuro/version/senmyou/base/remainder.rb +0 -60
  71. data/lib/zakuro/version/senmyou/base/solar_term.rb +0 -76
  72. data/lib/zakuro/version/senmyou/base/year.rb +0 -104
  73. data/lib/zakuro/version/senmyou/monthly/first_day.rb +0 -44
  74. data/lib/zakuro/version/senmyou/monthly/initialized_month.rb +0 -48
  75. data/lib/zakuro/version/senmyou/monthly/month.rb +0 -181
  76. data/lib/zakuro/version/senmyou/monthly/month_label.rb +0 -87
  77. data/lib/zakuro/version/senmyou/monthly/operated_month.rb +0 -167
  78. data/lib/zakuro/version/senmyou/range/full_range.rb +0 -324
  79. data/lib/zakuro/version/senmyou/range/operated_range.rb +0 -105
  80. data/lib/zakuro/version/senmyou/range/operated_solar_terms.rb +0 -163
  81. data/lib/zakuro/version/senmyou/specifier/single_day_specifier.rb +0 -99
  82. data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +0 -332
  83. data/lib/zakuro/version/senmyou/stella/solar_average.rb +0 -214
  84. data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +0 -394
  85. data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +0 -106
  86. data/lib/zakuro/version/senmyou/summary/single.rb +0 -71
@@ -0,0 +1,210 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../era/western'
4
+ require_relative '../../output/logger'
5
+
6
+ require_relative '../base/multi_gengou_roller'
7
+ require_relative '../base/year'
8
+
9
+ require_relative './transfer/year_boundary'
10
+ require_relative './transfer/western_date_allocation'
11
+
12
+ # :nodoc:
13
+ module Zakuro
14
+ # :nodoc:
15
+ module Calculation
16
+ # :nodoc:
17
+ module Range
18
+ # :reek:TooManyInstanceVariables { max_instance_variables: 6 }
19
+
20
+ #
21
+ # FullRange 完全範囲
22
+ # ある日からある日の範囲を計算可能な年月範囲
23
+ # * 前提として元号年はその元号の開始年から数える
24
+ # * ある日の元号年を求める場合、その元号が含まれる最初の年まで遡る
25
+ # * 元号は一つとは限らない。南北朝などで二つある場合は、古い方の元号から求める
26
+ #
27
+ # NOTE: 割り当てた元号は年初を基準にした元号年である
28
+ # * 元旦を基準にした時の正しい元号を設定している
29
+ # * 引き当てたい日付が元旦ではない場合、その月日に従い元号を再度求める
30
+ # * この再計算が必要になるのは、元号が切り替わる年のみである
31
+ #
32
+ class FullRange
33
+ # @return [Context] 暦コンテキスト
34
+ attr_reader :context
35
+ # @return [Western::Calendar] 開始日
36
+ attr_reader :start_date
37
+ # @return [Western::Calendar] 終了日
38
+ attr_reader :end_date
39
+ # @return [MultiGengouRoller] 改元処理
40
+ attr_reader :multi_gengou_roller
41
+ # @return [Western::Calendar] 最過去の元旦
42
+ attr_reader :new_year_date
43
+ # @return [Integer] 西暦年
44
+ attr_reader :western_year
45
+
46
+ # @return [Output::Logger] ロガー
47
+ LOGGER = Output::Logger.new(location: 'full_range')
48
+
49
+ #
50
+ # 初期化
51
+ #
52
+ # @param [Context] context 暦コンテキスト
53
+ # @param [Western::Calendar] start_date 開始日
54
+ # @param [Western::Calendar] end_date 終了日
55
+ #
56
+ def initialize(context:, start_date: Western::Calendar.new, end_date: Western::Calendar.new)
57
+ @start_date = start_date
58
+ @end_date = end_date
59
+ return if invalid?
60
+
61
+ @context = context
62
+ @multi_gengou_roller = Base::MultiGengouRoller.new(
63
+ start_date: start_date, end_date: end_date
64
+ )
65
+ @new_year_date = @multi_gengou_roller.oldest_date.clone
66
+ @western_year = @new_year_date.year
67
+ end
68
+
69
+ #
70
+ # 無効か
71
+ #
72
+ # @return [True] 無効
73
+ # @return [False] 有効
74
+ #
75
+ def invalid?
76
+ @start_date.invalid?
77
+ end
78
+
79
+ #
80
+ # 完全範囲を取得する
81
+ #
82
+ # @return [Array<Year>] 完全範囲
83
+ #
84
+ def get
85
+ return [] if invalid?
86
+
87
+ years = Transfer::YearBoundary.get(
88
+ context: @context, annual_ranges: annual_ranges
89
+ )
90
+ years = update_gengou(years: years)
91
+
92
+ Transfer::WesternDateAllocation.update_first_day(
93
+ context: @context, years: years
94
+ )
95
+
96
+ years
97
+ end
98
+
99
+ # :reek:TooManyStatements { max_statements: 7 }
100
+
101
+ #
102
+ # 完全範囲内の年データを取得する
103
+ #
104
+ # @return [Array<Year>] 年データ(冬至基準)
105
+ #
106
+ def annual_ranges
107
+ oldest_date = @new_year_date
108
+ newest_date = @multi_gengou_roller.newest_date
109
+ annual_range = context.resolver.annual_range
110
+
111
+ years = []
112
+ ((oldest_date.year)..(newest_date.year + 2)).each do |year|
113
+ years.push(
114
+ annual_range.get(
115
+ context: @context, western_year: year
116
+ )
117
+ )
118
+ end
119
+
120
+ years
121
+ end
122
+
123
+ # :reek:TooManyStatements { max_statements: 8 }
124
+
125
+ #
126
+ # 完全範囲内の年データの元号を開始年基準で更新する
127
+ #
128
+ # @param [Array<Year>] years 年データ(元旦基準)
129
+ #
130
+ # @return [Array<Year>] 元号更新済み年データ(元旦基準)
131
+ #
132
+ def update_gengou(years:)
133
+ updated_years = []
134
+
135
+ nearest_end_date = choise_nearest_end_date
136
+
137
+ years.each do |year|
138
+ next_year(years: updated_years, year: year)
139
+
140
+ if @new_year_date > nearest_end_date
141
+ @multi_gengou_roller.transfer
142
+ nearest_end_date = choise_nearest_end_date
143
+ end
144
+ @multi_gengou_roller.next_year
145
+ end
146
+
147
+ updated_years
148
+ end
149
+
150
+ private
151
+
152
+ #
153
+ # 元号処理対象の年を進める
154
+ #
155
+ # @param [Array<Year>] years 元号処理済み年データ(元旦基準)
156
+ # @param [Year] year 元号処理前の年(元旦基準)
157
+ #
158
+ def next_year(years:, year:)
159
+ updated_year = update_year(year: year)
160
+
161
+ years.push(updated_year)
162
+
163
+ next_new_year_date(total_days: updated_year.total_days)
164
+
165
+ nil
166
+ end
167
+
168
+ #
169
+ # 年の元号を更新する
170
+ #
171
+ # @param [Year] year 元号処理前の年(元旦基準)
172
+ #
173
+ # @return [Year] 元号処理済の年(元旦基準)
174
+ #
175
+ def update_year(year:)
176
+ multi_gengou = @multi_gengou_roller.multi_gengou.clone
177
+
178
+ updated_year = Base::Year.new(
179
+ multi_gengou: multi_gengou, new_year_date: @new_year_date.clone,
180
+ months: year.months
181
+ )
182
+ updated_year.commit
183
+
184
+ updated_year
185
+ end
186
+
187
+ #
188
+ # 次の年に進める
189
+ #
190
+ # @param [Integer] total_days 年の日数
191
+ #
192
+ def next_new_year_date(total_days:)
193
+ @new_year_date += total_days
194
+ @multi_gengou_roller.next(days: total_days)
195
+
196
+ nil
197
+ end
198
+
199
+ #
200
+ # 現在日からみて直近の未来に対する元号の切替前日を求める
201
+ #
202
+ # @return [Western::Calendar] 元号の切替前日
203
+ #
204
+ def choise_nearest_end_date
205
+ @multi_gengou_roller.choise_nearest_end_date
206
+ end
207
+ end
208
+ end
209
+ end
210
+ end
@@ -0,0 +1,144 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './operated_solar_terms'
4
+ require_relative '../../operation/operation'
5
+ require_relative '../../calculation/monthly/operated_month'
6
+
7
+ # :nodoc:
8
+ module Zakuro
9
+ # :nodoc:
10
+ module Calculation
11
+ # :nodoc:
12
+ module Range
13
+ #
14
+ # OperatedRange 運用結果範囲
15
+ #
16
+ # 何らかの理由により、計算された暦とは異なる運用結果である場合、その結果に合わせて計算結果を上書きする
17
+ class OperatedRange
18
+ # @return [Array<Year>] 年データ(完全範囲)
19
+ attr_reader :years
20
+ # @return [OperatedSolarTerms] 運用時二十四節気
21
+ attr_reader :operated_solar_terms
22
+ # @return [Context] 暦コンテキスト
23
+ attr_reader :context
24
+
25
+ #
26
+ # 初期化
27
+ #
28
+ # @param [Context] context 暦コンテキスト
29
+ # @param [Array<Year>] years 年データ(完全範囲)
30
+ #
31
+ def initialize(context:, years: [])
32
+ @context = context
33
+ @years = years
34
+ @operated_solar_terms = OperatedSolarTerms.new(context: context, years: @years)
35
+ @operated_solar_terms.create
36
+ end
37
+
38
+ #
39
+ # 運用結果範囲を取得する
40
+ #
41
+ # @return [Array<Year>] 運用結果範囲
42
+ #
43
+ def get
44
+ rewrite
45
+ end
46
+
47
+ #
48
+ # 運用結果に書き換える
49
+ #
50
+ # @return [Array<Year>] 運用結果範囲
51
+ #
52
+ def rewrite
53
+ operated_years = []
54
+
55
+ years.each do |year|
56
+ operated_year = OperatedRange.rewrite_year(
57
+ context: context, year: year,
58
+ operated_solar_terms: @operated_solar_terms
59
+ )
60
+ operated_years.push(operated_year)
61
+ end
62
+
63
+ operated_years
64
+ end
65
+
66
+ #
67
+ # 年を書き換える
68
+ #
69
+ # @param [Context] context 暦コンテキスト
70
+ # @param [Year] year 年
71
+ # @param [OperatedSolarTerms] operated_solar_terms 運用時二十四節気
72
+ #
73
+ # @return [Year] 年
74
+ #
75
+ def self.rewrite_year(context:, year:, operated_solar_terms:)
76
+ result = Base::Year.new(
77
+ multi_gengou: year.multi_gengou, new_year_date: year.new_year_date
78
+ )
79
+ year.months.each do |month|
80
+ result.push(month: resolve_month(
81
+ context: context, month: month,
82
+ operated_solar_terms: operated_solar_terms
83
+ ))
84
+ end
85
+
86
+ result.commit
87
+
88
+ result
89
+ end
90
+
91
+ #
92
+ # 履歴情報の有無に応じた月にする
93
+ #
94
+ # @param [Context] context 暦コンテキスト
95
+ # @param [Month] month 月
96
+ # @param [OperatedSolarTerms] operated_solar_terms 運用時二十四節気
97
+ #
98
+ # @return [Month] 月
99
+ #
100
+ def self.resolve_month(context:, month:, operated_solar_terms:)
101
+ history = Operation.specify_history(western_date: month.western_date)
102
+
103
+ return month if history.invalid?
104
+
105
+ OperatedRange.rewrite_month(
106
+ context: context, month: month, history: history,
107
+ operated_solar_terms: operated_solar_terms
108
+ )
109
+ end
110
+
111
+ # :reek:LongParameterList {max_params: 4}
112
+
113
+ #
114
+ # 月を運用結果に書き換える
115
+ #
116
+ # @param [Context] context 暦コンテキスト
117
+ # @param [Month] month 月
118
+ # @param [Operation::MonthHistory] history 変更履歴
119
+ # @param [OperatedSolarTerms] operated_solar_terms 運用時二十四節気
120
+ #
121
+ # @return [Month] 月(運用結果)
122
+ #
123
+ def self.rewrite_month(context:, month:, history:, operated_solar_terms:)
124
+ return month unless month.western_date == history.western_date
125
+
126
+ operated_month = Monthly::OperatedMonth.new(
127
+ context: context,
128
+ month_label: month.month_label, first_day: month.first_day,
129
+ solar_terms: month.solar_terms, history: history,
130
+ operated_solar_terms: operated_solar_terms
131
+ )
132
+
133
+ operated_month.rewrite
134
+
135
+ Monthly::Month.new(
136
+ context: context,
137
+ month_label: operated_month.month_label, first_day: operated_month.first_day,
138
+ solar_terms: operated_month.solar_terms
139
+ )
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,201 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../operation/operation'
4
+ require_relative '../monthly/month'
5
+
6
+ # TODO: solar_termの中はsrc/destだが、yamlはcalc/actual。統一したい。
7
+
8
+ # :nodoc:
9
+ module Zakuro
10
+ # :nodoc:
11
+ module Calculation
12
+ # :nodoc:
13
+ module Range
14
+ #
15
+ # OperatedSolarTerm 運用時二十四節気
16
+ #
17
+ class OperatedSolarTerms
18
+ # @return [Array<Year>] 完全範囲(年データ)
19
+ attr_reader :years
20
+ # @return [Hash<String, SolarTerm>] 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
21
+ #
22
+ # * 移動元の二十四節気:無効な大余小余あり(削除対象)
23
+ # * 移動先の二十四節気:移動元からの二十四節気(追加対象)
24
+ #
25
+ attr_reader :directions
26
+ # @return [Context] 暦コンテキスト
27
+ attr_reader :context
28
+
29
+ #
30
+ # 初期化
31
+ #
32
+ # @param [Context] context 暦コンテキスト
33
+ # @param [Array<Year>] years 完全範囲(年データ)
34
+ #
35
+ def initialize(context:, years: [])
36
+ @context = context
37
+ @years = years
38
+ @directions = {}
39
+ end
40
+
41
+ #
42
+ # データ生成する
43
+ #
44
+ # @return [<Type>] <description>
45
+ #
46
+ def create
47
+ @directions = create_directions
48
+ end
49
+
50
+ #
51
+ # 二十四節気を取得する
52
+ #
53
+ # @param [Western::Calendar] western_date 月初日の西暦日
54
+ #
55
+ # @return [True] 対象あり
56
+ # @return [False] 対象なし
57
+ # @return [SolarTerm] 二十四節気
58
+ #
59
+ def get(western_date: Western::Calendar.new)
60
+ solar_term_class = context.resolver.solar_term
61
+ solar_term = @directions.fetch(western_date.format, solar_term_class.new)
62
+
63
+ # 合致しない場合
64
+ return false, solar_term_class.new if solar_term.empty?
65
+
66
+ # 合致した上で、二十四節気が移動元(削除対象)の場合
67
+ # 合致した上で、二十四節気が移動先(追加対象)の場合
68
+ [true, solar_term]
69
+ end
70
+
71
+ #
72
+ # 二十四節気の移動元/移動先を生成する
73
+ #
74
+ # @return [Hash<String, SolarTerm>] 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
75
+ #
76
+ def create_directions
77
+ directions = {}
78
+
79
+ years.each do |year|
80
+ OperatedSolarTerms.create_directions_with_months(
81
+ context: context, directions: directions, months: year.months
82
+ )
83
+ end
84
+
85
+ directions
86
+ end
87
+
88
+ # :reek:TooManyStatements { max_statements: 6 }
89
+
90
+ #
91
+ # 年内の全ての月の移動方向を作成する
92
+ #
93
+ # @param [Context] context 暦コンテキスト
94
+ # @param [Hash<String, SolarTerm>] directions 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
95
+ # @param [Array<Month>] months 年内の全ての月
96
+ #
97
+ def self.create_directions_with_months(context:, directions: {}, months: [])
98
+ months.each do |month|
99
+ history = Operation.specify_history(western_date: month.western_date)
100
+
101
+ next if history.invalid?
102
+
103
+ direction = history.diffs.solar_term
104
+
105
+ next if direction.invalid?
106
+
107
+ OperatedSolarTerms.create_directions_each_month(
108
+ context: context, directions: directions, direction: direction, month: month
109
+ )
110
+ end
111
+ end
112
+
113
+ # :reek:LongParameterList {max_params: 4}
114
+
115
+ #
116
+ # 月毎の移動方向を作成する
117
+ #
118
+ # @param [Context] context 暦コンテキスト
119
+ # @param [Month] 月
120
+ # @param [Hash<String, SolarTerm>] directions 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
121
+ # @param [Operation::SolarTerm::Diretion] 二十四節気(移動)
122
+ #
123
+ def self.create_directions_each_month(context:, month:, directions: {},
124
+ direction: Operation::SolarTerm::Diretion.new)
125
+
126
+ month.solar_terms.each do |solar_term|
127
+ OperatedSolarTerms.push_source(context: context, directions: directions,
128
+ direction: direction, solar_term: solar_term)
129
+ end
130
+ OperatedSolarTerms.push_destination(context: context, directions: directions,
131
+ destination: direction.destination)
132
+ end
133
+
134
+ # :reek:LongParameterList {max_params: 4}
135
+
136
+ #
137
+ # 移動先に有効な二十四節気(差し替える二十四節気)を指定する
138
+ #
139
+ # @param [Context] context 暦コンテキスト
140
+ # @param [SolarTerm] solar_term 二十四節気(計算値)
141
+ # @param [Hash<String, SolarTerm>] directions 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
142
+ # @param [Operation::SolarTerm::Direction] source 二十四節気(移動)
143
+ #
144
+ def self.push_source(context:, solar_term:, directions: {},
145
+ direction: Operation::SolarTerm::Direction.new)
146
+ source = direction.source
147
+
148
+ return if source.invalid?
149
+
150
+ return unless source.index == solar_term.index
151
+
152
+ # 移動先に移動元の二十四節気を指定する
153
+ directions[source.to.format] = OperatedSolarTerms.created_source(
154
+ context: context, direction: direction, solar_term: solar_term
155
+ )
156
+ end
157
+
158
+ #
159
+ # 移動先に有効な二十四節気(差し替える二十四節気)を生成する
160
+ #
161
+ # @param [Context] context 暦コンテキスト
162
+ # @param [SolarTerm] solar_term 二十四節気(計算値)
163
+ # @param [Operation::SolarTerm::Direction] source 二十四節気(移動)
164
+ #
165
+ # @return [SolarTerm] 二十四節気(運用値)
166
+ #
167
+ def self.created_source(context:, solar_term:,
168
+ direction: Operation::SolarTerm::Direction.new)
169
+ operated_solar_term = solar_term.clone
170
+ remainder_class_name = context.resolver.remainder
171
+
172
+ unless direction.invalid_days?
173
+ # 二十四節気の大余をずらす
174
+ operated_solar_term.remainder.add!(
175
+ remainder_class_name.new(day: direction.days, minute: 0, second: 0)
176
+ )
177
+ end
178
+
179
+ operated_solar_term
180
+ end
181
+
182
+ #
183
+ # 移動元に無効な二十四節気(連番のみ指定)を指定する
184
+ #
185
+ # @param [Context] context 暦コンテキスト
186
+ # @param [Hash<String, SolarTerm>] directions 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
187
+ # @param [Operation::SolarTerm::Destination] destination 二十四節気(移動先)
188
+ #
189
+ def self.push_destination(context:, directions: {},
190
+ destination: Operation::SolarTerm::Destination.new)
191
+ return if destination.invalid?
192
+
193
+ solar_term_class = context.resolver.solar_term
194
+ directions[destination.from.format] = solar_term_class.new(
195
+ index: destination.index
196
+ )
197
+ end
198
+ end
199
+ end
200
+ end
201
+ end