zakuro 0.9.2 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/doc/dropped_date.md +25 -0
- data/doc/operation/csv/month.csv +4 -5
- data/doc/operation/operation.xlsx +0 -0
- data/doc/vanished_date.md +26 -0
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +26 -0
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +7 -1
- data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +8 -2
- data/lib/zakuro/calculation/era/gengou/internal/counter.rb +5 -5
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +18 -5
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +24 -9
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +7 -2
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +7 -2
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +13 -3
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +15 -4
- data/lib/zakuro/calculation/era/gengou/named_scroll.rb +8 -2
- data/lib/zakuro/calculation/monthly/initialized_month.rb +4 -2
- data/lib/zakuro/calculation/monthly/meta/all_solar_term.rb +64 -0
- data/lib/zakuro/calculation/monthly/meta/meta_collector.rb +80 -0
- data/lib/zakuro/calculation/monthly/meta.rb +60 -0
- data/lib/zakuro/calculation/monthly/month.rb +119 -5
- data/lib/zakuro/calculation/monthly/operated_month.rb +7 -19
- data/lib/zakuro/calculation/option/dropped_date/location.rb +20 -24
- data/lib/zakuro/calculation/option/vanished_date/location.rb +9 -2
- data/lib/zakuro/calculation/range/abstract_full_range.rb +19 -2
- data/lib/zakuro/calculation/range/abstract_operation_range.rb +20 -2
- data/lib/zakuro/calculation/range/dated_full_range.rb +8 -3
- data/lib/zakuro/calculation/range/dated_operation_range.rb +4 -1
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +1 -1
- data/lib/zakuro/calculation/range/named_full_range.rb +3 -1
- data/lib/zakuro/calculation/range/named_operation_range.rb +3 -1
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +2 -1
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +10 -8
- data/lib/zakuro/calculation/stella/solar/abstract_average.rb +8 -34
- data/lib/zakuro/calculation/summary/internal/option.rb +24 -5
- data/lib/zakuro/calculation/summary/western/range.rb +8 -1
- data/lib/zakuro/calculation/summary/western/single.rb +12 -5
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +1 -1
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +1 -1
- data/lib/zakuro/era/japan/gengou/alignment.rb +41 -2
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +83 -25
- data/lib/zakuro/era/japan/gengou/resource/type.rb +81 -26
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +100 -21
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml +1123 -375
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-002-from-north.yaml +487 -163
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-003-modern.yaml +30 -10
- data/lib/zakuro/era/japan/gengou/resource.rb +16 -0
- data/lib/zakuro/era/japan/gengou.rb +11 -6
- data/lib/zakuro/operation/yaml/month.yaml +4 -36
- data/lib/zakuro/output/logger.rb +21 -3
- data/lib/zakuro/tools/gengou_range_comparer.rb +82 -0
- data/lib/zakuro/tools/remainder_comparer.rb +100 -0
- metadata +11 -6
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../era/western/calendar'
|
4
|
+
|
5
|
+
require_relative '../month'
|
6
|
+
|
7
|
+
require_relative './all_solar_term'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
# :nodoc:
|
12
|
+
module Calculation
|
13
|
+
# :nodoc:
|
14
|
+
module Monthly
|
15
|
+
#
|
16
|
+
# MetaCollector メタ情報の収集
|
17
|
+
#
|
18
|
+
# 前月データを次のように扱う
|
19
|
+
# 1. 範囲内の最初の月は無視する
|
20
|
+
# * 元号範囲は常に余裕を持って取っている
|
21
|
+
# * 求めたい日付よりは常に1ヶ月以上を計算範囲にしている
|
22
|
+
# * 元嘉暦の最初の月は無視する
|
23
|
+
# * 元嘉暦は正月始まり
|
24
|
+
# * 初めの月は手前の月がないため前月がない
|
25
|
+
# * 没日・滅日の対象外のため不要とする
|
26
|
+
# 2. 年境界を解決した後の1年データで再度移行する
|
27
|
+
# * 冬至データの最初の月には前月がない
|
28
|
+
# * 1年データにすることで前月が生まれるので再度移行する
|
29
|
+
# 3. 暦の切り替えを考慮する
|
30
|
+
# * 手前の月が異なる暦であれば、その月のデータを参照する
|
31
|
+
module MetaCollector
|
32
|
+
class << self
|
33
|
+
#
|
34
|
+
# メタ情報を取得する
|
35
|
+
#
|
36
|
+
# @param [Monthly::Month] before_month 前月
|
37
|
+
# @param [Monthly::Month] current_month 当月
|
38
|
+
#
|
39
|
+
# @return [Monthly::Meta] 当月のメタ情報
|
40
|
+
#
|
41
|
+
def get(before_month:, current_month:)
|
42
|
+
Monthly::Meta.new(
|
43
|
+
all_solar_terms: all_solar_terms(
|
44
|
+
before_month: before_month, current_month: current_month
|
45
|
+
),
|
46
|
+
last_average_remainder: last_average_remainder(
|
47
|
+
before_month: before_month
|
48
|
+
)
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
#
|
55
|
+
# 全ての二十四節気を取得する
|
56
|
+
#
|
57
|
+
# @param [Monthly::Month] before_month 前月
|
58
|
+
# @param [Monthly::Month] current_month 当月
|
59
|
+
#
|
60
|
+
# @return [Array<Cycle::AbstractSolarTerm>] その月の全ての二十四節気
|
61
|
+
#
|
62
|
+
def all_solar_terms(before_month:, current_month:)
|
63
|
+
AllSolarTerm.get(before_month: before_month, current_month: current_month)
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# 前月の経朔を取得する
|
68
|
+
#
|
69
|
+
# @param [Monthly::Month] before_month 前月
|
70
|
+
#
|
71
|
+
# @return [Cycle::AbstractRemainder] 前月の経朔
|
72
|
+
#
|
73
|
+
def last_average_remainder(before_month:)
|
74
|
+
before_month.first_day.average_remainder
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../cycle/abstract_remainder'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
# :nodoc:
|
8
|
+
module Calculation
|
9
|
+
# :nodoc:
|
10
|
+
module Monthly
|
11
|
+
#
|
12
|
+
# Meta 付加情報
|
13
|
+
#
|
14
|
+
class Meta
|
15
|
+
# @return [Array<Cycle::AbstractSolarTerm>] 月の全ての二十四節気
|
16
|
+
# @note 前提として、『日本暦日原典』にある月ごとの二十四節気は、その月の全ての二十四節気ではない
|
17
|
+
#
|
18
|
+
# 下表を例に取った場合、『日本暦日原典』の二十四節気連番のうち、2と3がその月の二十四節気となる
|
19
|
+
# ここで、当月のうち2より手前の日は前月の1の二十四節気に属しており、当月だけでは参照できない
|
20
|
+
# この参照を可能とするための情報となる
|
21
|
+
#
|
22
|
+
# |No| 項目 | 前月 | 当月 | 次月 |
|
23
|
+
# |1 | 月 | month[index - 1] | month[index] | month[index + 1] |
|
24
|
+
# |2 | 考えられる範囲 | |-------------------| |
|
25
|
+
# |3 | 二十四節気連番 | 0 1 | 2 3 | 4 5 |
|
26
|
+
# |4 | 二十四節気大余 | 55 10 | 25 40 | 55 5 |
|
27
|
+
#
|
28
|
+
attr_reader :all_solar_terms
|
29
|
+
|
30
|
+
# @return [Cycle::AbstractRemainder] 前月の平朔
|
31
|
+
# @note 滅日計算に用いる
|
32
|
+
#
|
33
|
+
# 月の1日目で前月からの平朔が用いられている
|
34
|
+
#
|
35
|
+
attr_reader :last_average_remainder
|
36
|
+
|
37
|
+
#
|
38
|
+
# 初期化
|
39
|
+
#
|
40
|
+
# @param [Array<AbstractSolarTerm>] all_solar_terms 月の全ての二十四節気
|
41
|
+
# @param [Cycle::AbstractRemainder] last_average_remainder 前月の平朔
|
42
|
+
#
|
43
|
+
def initialize(all_solar_terms: [], last_average_remainder: Cycle::AbstractRemainder.new)
|
44
|
+
@all_solar_terms = all_solar_terms
|
45
|
+
@last_average_remainder = last_average_remainder
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# ディープコピー
|
50
|
+
#
|
51
|
+
# @param [Meta] obj 自身
|
52
|
+
#
|
53
|
+
def initialize_copy(obj)
|
54
|
+
@all_solar_terms = obj.all_solar_terms.clone
|
55
|
+
@last_average_remainder = obj.last_average_remainder.clone
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -1,8 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../cycle/abstract_solar_term'
|
4
|
+
|
3
5
|
require_relative '../base/gengou'
|
4
6
|
require_relative './first_day'
|
7
|
+
require_relative './meta'
|
5
8
|
require_relative './month_label'
|
9
|
+
require_relative './meta/meta_collector'
|
6
10
|
|
7
11
|
# :nodoc:
|
8
12
|
module Zakuro
|
@@ -20,10 +24,14 @@ module Zakuro
|
|
20
24
|
attr_reader :month_label
|
21
25
|
# @return [FirstDay] 月初日(朔日)
|
22
26
|
attr_reader :first_day
|
23
|
-
# @return [Array<
|
27
|
+
# @return [Array<Cyle::AbstractSolarTerm>] 二十四節気
|
24
28
|
attr_reader :solar_terms
|
25
29
|
# @return [Base::Gengou] 元号
|
26
30
|
attr_reader :gengou
|
31
|
+
# @return [Meta] 付加情報
|
32
|
+
attr_reader :meta
|
33
|
+
|
34
|
+
# rubocop:disable Metrics/ParameterLists
|
27
35
|
|
28
36
|
#
|
29
37
|
# 初期化
|
@@ -31,18 +39,23 @@ module Zakuro
|
|
31
39
|
# @param [Context::Context] context 暦コンテキスト
|
32
40
|
# @param [MonthLabel] month_label 月表示名
|
33
41
|
# @param [FirstDay] first_day 月初日(朔日)
|
34
|
-
# @param [Array<
|
42
|
+
# @param [Array<Cyle::AbstractSolarTerm>] solar_terms 二十四節気
|
35
43
|
# @param [Base::Gengou] gengou 元号
|
44
|
+
# @param [Meta] meta 付加情報
|
36
45
|
#
|
37
46
|
def initialize(context: Context::Context.new, month_label: MonthLabel.new,
|
38
|
-
first_day: FirstDay.new, solar_terms: [], gengou: Base::Gengou.new
|
47
|
+
first_day: FirstDay.new, solar_terms: [], gengou: Base::Gengou.new,
|
48
|
+
meta: Meta.new)
|
39
49
|
@context = context
|
40
50
|
@month_label = month_label
|
41
51
|
@first_day = first_day
|
42
52
|
@solar_terms = solar_terms
|
43
53
|
@gengou = gengou
|
54
|
+
@meta = meta
|
44
55
|
end
|
45
56
|
|
57
|
+
# rubocop:enable Metrics/ParameterLists
|
58
|
+
|
46
59
|
#
|
47
60
|
# 不正か
|
48
61
|
#
|
@@ -153,7 +166,7 @@ module Zakuro
|
|
153
166
|
#
|
154
167
|
# 中気を返す
|
155
168
|
#
|
156
|
-
# @return [
|
169
|
+
# @return [Cycle::AbstractSolarTerm] 中気
|
157
170
|
#
|
158
171
|
def even_term
|
159
172
|
solar_terms.each do |term|
|
@@ -166,7 +179,7 @@ module Zakuro
|
|
166
179
|
#
|
167
180
|
# 節気を返す
|
168
181
|
#
|
169
|
-
# @return [
|
182
|
+
# @return [Cycle::AbstractSolarTerm] 節気
|
170
183
|
#
|
171
184
|
def odd_term
|
172
185
|
solar_terms.each do |term|
|
@@ -250,6 +263,82 @@ module Zakuro
|
|
250
263
|
same_by_japan_date?(date: date)
|
251
264
|
end
|
252
265
|
|
266
|
+
#
|
267
|
+
# 二十四節気を正しい順序にソートする
|
268
|
+
#
|
269
|
+
def sort_solar_terms
|
270
|
+
# TODO: refactor
|
271
|
+
sorted = (solar_terms.sort do |termx, termy|
|
272
|
+
termx.index <=> termy.index
|
273
|
+
end)
|
274
|
+
|
275
|
+
unless reset_term?(solar_terms: sorted)
|
276
|
+
@solar_terms = sorted
|
277
|
+
return
|
278
|
+
end
|
279
|
+
|
280
|
+
first = []
|
281
|
+
second = []
|
282
|
+
|
283
|
+
sorted.each do |term|
|
284
|
+
if term.index >= (23 - 2)
|
285
|
+
second.push(term)
|
286
|
+
next
|
287
|
+
end
|
288
|
+
|
289
|
+
first.push(term)
|
290
|
+
end
|
291
|
+
|
292
|
+
# 0以前を先頭にする
|
293
|
+
second += first
|
294
|
+
|
295
|
+
@solar_terms = second
|
296
|
+
end
|
297
|
+
|
298
|
+
#
|
299
|
+
# 大余に対応する二十四節気
|
300
|
+
#
|
301
|
+
# @param [Integer] day 大余
|
302
|
+
#
|
303
|
+
# @return [Cycle::AbstractSolarTerm] 二十四節気
|
304
|
+
#
|
305
|
+
def solar_term_by_day(day:)
|
306
|
+
# TODO: refactor
|
307
|
+
target = context.resolver.remainder.new(day: day, minute: 0, second: 0)
|
308
|
+
|
309
|
+
meta.all_solar_terms.each_cons(2) do |current_solar_term, next_solar_term|
|
310
|
+
in_range = Tools::RemainderComparer.in_range?(
|
311
|
+
target: target, start: current_solar_term.remainder, last: next_solar_term.remainder
|
312
|
+
)
|
313
|
+
return current_solar_term if in_range
|
314
|
+
end
|
315
|
+
|
316
|
+
last_solar_term = meta.all_solar_terms[-1]
|
317
|
+
|
318
|
+
empty_solar_term = context.resolver.solar_term.new
|
319
|
+
|
320
|
+
return empty_solar_term unless last_solar_term
|
321
|
+
# NOTE: 大余20を上限として範囲チェックする
|
322
|
+
if Tools::RemainderComparer.in_limit?(target: target, start: last_solar_term.remainder,
|
323
|
+
limit: 20)
|
324
|
+
return last_solar_term
|
325
|
+
end
|
326
|
+
|
327
|
+
empty_solar_term
|
328
|
+
end
|
329
|
+
|
330
|
+
#
|
331
|
+
# メタ情報を再設定する
|
332
|
+
#
|
333
|
+
# @param [Month] last 前月
|
334
|
+
#
|
335
|
+
def reset_meta(last: Month.new)
|
336
|
+
@meta = MetaCollector.get(
|
337
|
+
before_month: last,
|
338
|
+
current_month: self
|
339
|
+
)
|
340
|
+
end
|
341
|
+
|
253
342
|
private
|
254
343
|
|
255
344
|
#
|
@@ -267,6 +356,31 @@ module Zakuro
|
|
267
356
|
|
268
357
|
true
|
269
358
|
end
|
359
|
+
|
360
|
+
#
|
361
|
+
# 二十四節気の折り返し(23 -> 0)があるか
|
362
|
+
#
|
363
|
+
# @param [Array<Cyle::AbstractSolarTerm>] solar_terms 二十四節気
|
364
|
+
#
|
365
|
+
# @return [True] 折り返しあり
|
366
|
+
# @return [False] 折り返しなし
|
367
|
+
#
|
368
|
+
def reset_term?(solar_terms: [])
|
369
|
+
first = false
|
370
|
+
last = false
|
371
|
+
|
372
|
+
solar_terms.each do |term|
|
373
|
+
index = term.index
|
374
|
+
case index
|
375
|
+
when Cycle::AbstractSolarTerm::FIRST_INDEX
|
376
|
+
first = true
|
377
|
+
when Cycle::AbstractSolarTerm::LAST_INDEX
|
378
|
+
last = true
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
first && last
|
383
|
+
end
|
270
384
|
end
|
271
385
|
end
|
272
386
|
end
|
@@ -33,12 +33,13 @@ module Zakuro
|
|
33
33
|
# @param [FirstDay] first_day 月初日(朔日)
|
34
34
|
# @param [Array<SolarTerm>] solar_terms 二十四節気
|
35
35
|
# @param [Operation::MonthHistory] history 変更履歴(月)
|
36
|
+
# @param [Meta] meta 付加情報
|
36
37
|
#
|
37
38
|
def initialize(context:, operated_solar_term:, month_label: MonthLabel.new,
|
38
39
|
first_day: FirstDay.new, solar_terms: [], gengou: Base::Gengou.new,
|
39
|
-
history: Operation::MonthHistory.new)
|
40
|
+
history: Operation::MonthHistory.new, meta: Meta.new)
|
40
41
|
super(context: context, month_label: month_label, first_day: first_day,
|
41
|
-
solar_terms: solar_terms, gengou: gengou)
|
42
|
+
solar_terms: solar_terms, gengou: gengou, meta: meta)
|
42
43
|
@history = history
|
43
44
|
@operated_solar_term = operated_solar_term
|
44
45
|
@moved = false
|
@@ -53,6 +54,8 @@ module Zakuro
|
|
53
54
|
rewrite_month
|
54
55
|
rewrite_solar_terms
|
55
56
|
rewrite_first_day
|
57
|
+
|
58
|
+
sort_solar_terms
|
56
59
|
end
|
57
60
|
|
58
61
|
#
|
@@ -102,7 +105,8 @@ module Zakuro
|
|
102
105
|
@first_day = FirstDay.new(
|
103
106
|
western_date: rewrite_western_date(days: days),
|
104
107
|
remainder: rewrite_remainder(days: days),
|
105
|
-
|
108
|
+
# NOTE: 『日本暦日便覧』では滅日を計算値で求めている。運用値への書き換えは実施しない
|
109
|
+
average_remainder: first_day.average_remainder.clone
|
106
110
|
)
|
107
111
|
end
|
108
112
|
|
@@ -122,22 +126,6 @@ module Zakuro
|
|
122
126
|
remainder
|
123
127
|
end
|
124
128
|
|
125
|
-
#
|
126
|
-
# 月初日の大余小余を日差分で書き換える(経朔)
|
127
|
-
#
|
128
|
-
# @param [Integer] days 日差分
|
129
|
-
#
|
130
|
-
# @return [Remainder] 月初日の大余小余
|
131
|
-
#
|
132
|
-
def rewrite_average_remainder(days:)
|
133
|
-
remainder = first_day.average_remainder.clone
|
134
|
-
remainder.add!(
|
135
|
-
context.resolver.remainder.new(day: days, minute: 0, second: 0)
|
136
|
-
)
|
137
|
-
|
138
|
-
remainder
|
139
|
-
end
|
140
|
-
|
141
129
|
#
|
142
130
|
# 月初日の西暦日を日差分で書き換える
|
143
131
|
#
|
@@ -24,8 +24,8 @@ module Zakuro
|
|
24
24
|
attr_reader :limit
|
25
25
|
# @return [Integer] 年
|
26
26
|
attr_reader :year
|
27
|
-
# @return [
|
28
|
-
attr_reader :
|
27
|
+
# @return [Cycle::AbstractSolarTerm] 二十四節気
|
28
|
+
attr_reader :solar_term
|
29
29
|
# @return [Class] 没余クラス
|
30
30
|
attr_reader :remainder_class
|
31
31
|
|
@@ -33,16 +33,16 @@ module Zakuro
|
|
33
33
|
# 初期化
|
34
34
|
#
|
35
35
|
# @param [Context::Context] context 暦コンテキスト
|
36
|
-
# @param [
|
36
|
+
# @param [Cycle::AbstractSolarTerm] solar_term 二十四節気
|
37
37
|
#
|
38
|
-
def initialize(context:,
|
38
|
+
def initialize(context:, solar_term:)
|
39
39
|
parameter = context.resolver.dropped_date_parameter.new
|
40
40
|
@context = context
|
41
41
|
@valid = parameter.valid
|
42
42
|
@limit = parameter.limit
|
43
43
|
@year = parameter.year
|
44
44
|
@remainder_class = parameter.remainder_class
|
45
|
-
@
|
45
|
+
@solar_term = solar_term
|
46
46
|
end
|
47
47
|
|
48
48
|
#
|
@@ -62,7 +62,14 @@ module Zakuro
|
|
62
62
|
# @return [False] 存在なし
|
63
63
|
#
|
64
64
|
def exist?
|
65
|
-
|
65
|
+
remainder = solar_term_remainder
|
66
|
+
|
67
|
+
return false if remainder.invalid?
|
68
|
+
|
69
|
+
minute_later = remainder.class.new(
|
70
|
+
day: 0, minute: remainder.minute, second: remainder.second
|
71
|
+
)
|
72
|
+
minute_later >= limit
|
66
73
|
end
|
67
74
|
|
68
75
|
#
|
@@ -73,36 +80,25 @@ module Zakuro
|
|
73
80
|
def get
|
74
81
|
# 1. 二十四節気の大余小余を取り出す
|
75
82
|
remainder = solar_term_remainder
|
83
|
+
|
84
|
+
# p "remainder: #{remainder.format(form: '%d-%d.%.5f')}"
|
85
|
+
|
76
86
|
# 2. 小余360、秒45(360/8)で乗算する
|
77
87
|
total = multiple_ideal_year(remainder: remainder)
|
88
|
+
# p "total: #{total}"
|
78
89
|
# 3. 上記2と章歳(3068055)の差を求める
|
79
90
|
diff = (year - total).abs
|
91
|
+
# p "year: #{year}"
|
92
|
+
# p "diff: #{diff}"
|
80
93
|
# 4. 上記3を通余で徐算する
|
81
94
|
result = remainder_class.new(total: diff)
|
95
|
+
# p "result: #{result.format(form: '%d-%d.%.5f')}"
|
82
96
|
# 5. 上記4の商と上記1の大余が没日大余、余りが小余(没余)
|
83
97
|
day = remainder_class.new(day: remainder.day, minute: 0, second: 0)
|
84
98
|
|
85
99
|
day.add(result)
|
86
100
|
end
|
87
101
|
|
88
|
-
#
|
89
|
-
# 該当の二十四節気を取得する
|
90
|
-
#
|
91
|
-
# @return [Cycle::AbstractSolarTerm] 二十四節気
|
92
|
-
#
|
93
|
-
def solar_term
|
94
|
-
solar_terms.each do |solar_term|
|
95
|
-
remainder = solar_term.remainder.clone
|
96
|
-
minute_later = remainder.class.new(
|
97
|
-
day: 0, minute: remainder.minute, second: remainder.second
|
98
|
-
)
|
99
|
-
|
100
|
-
return solar_term if minute_later >= limit
|
101
|
-
end
|
102
|
-
|
103
|
-
context.resolver.solar_term.new
|
104
|
-
end
|
105
|
-
|
106
102
|
private
|
107
103
|
|
108
104
|
#
|
@@ -72,10 +72,17 @@ module Zakuro
|
|
72
72
|
#
|
73
73
|
def get
|
74
74
|
# 経朔の小余 * 30
|
75
|
-
minute = remainder_class.new(
|
75
|
+
minute = remainder_class.new(
|
76
|
+
day: 0, minute: IDEAL_MONTH * average_remainder.minute, second: 0
|
77
|
+
)
|
78
|
+
|
76
79
|
day = remainder_class.new(day: average_remainder.day, minute: 0, second: 0)
|
77
80
|
|
78
|
-
minute.add(day)
|
81
|
+
minute.add!(day)
|
82
|
+
|
83
|
+
# p "location.minute: #{minute.format}"
|
84
|
+
|
85
|
+
minute
|
79
86
|
end
|
80
87
|
end
|
81
88
|
end
|
@@ -20,8 +20,6 @@ module Zakuro
|
|
20
20
|
module Calculation
|
21
21
|
# :nodoc:
|
22
22
|
module Range
|
23
|
-
# :reek:TooManyInstanceVariables { max_instance_variables: 6 }
|
24
|
-
|
25
23
|
#
|
26
24
|
# FullRange 完全範囲
|
27
25
|
# ある日からある日の範囲を計算可能な年月範囲
|
@@ -89,6 +87,8 @@ module Zakuro
|
|
89
87
|
|
90
88
|
Transfer::GengouScroller.set(scroll: scroll, years: years)
|
91
89
|
|
90
|
+
reset_meta(years: years)
|
91
|
+
|
92
92
|
years
|
93
93
|
end
|
94
94
|
|
@@ -104,6 +104,7 @@ module Zakuro
|
|
104
104
|
last_year = scroll.western_last_year
|
105
105
|
|
106
106
|
# TODO: context にデフォルト暦名が設定されている場合は使用しない
|
107
|
+
# 現在は暦ごとの元号情報がないため使用できない
|
107
108
|
versions = Version.get(start_year: start_year, last_year: last_year)
|
108
109
|
|
109
110
|
collect_version_ranges(versions: versions, start_year: start_year, last_year: last_year)
|
@@ -181,6 +182,22 @@ module Zakuro
|
|
181
182
|
|
182
183
|
result
|
183
184
|
end
|
185
|
+
|
186
|
+
#
|
187
|
+
# メタ情報を更新する
|
188
|
+
#
|
189
|
+
# @param [Array<Base::Year>] years 完全範囲
|
190
|
+
#
|
191
|
+
def reset_meta(years: [])
|
192
|
+
months = []
|
193
|
+
years.each do |year|
|
194
|
+
months |= year.months
|
195
|
+
end
|
196
|
+
|
197
|
+
months.each_cons(2) do |last, current|
|
198
|
+
current.reset_meta(last: last)
|
199
|
+
end
|
200
|
+
end
|
184
201
|
end
|
185
202
|
end
|
186
203
|
end
|
@@ -53,6 +53,8 @@ module Zakuro
|
|
53
53
|
|
54
54
|
Transfer::GengouScroller.set(scroll: @scroll, years: operated_years)
|
55
55
|
|
56
|
+
self.class.reset_meta(years: operated_years)
|
57
|
+
|
56
58
|
operated_years
|
57
59
|
end
|
58
60
|
|
@@ -172,20 +174,36 @@ module Zakuro
|
|
172
174
|
# @param [Operation::MonthHistory] history 変更履歴
|
173
175
|
# @param [OperatedSolarTerm] operated_solar_term 運用時二十四節気
|
174
176
|
#
|
175
|
-
# @return [Month] 月(運用結果)
|
177
|
+
# @return [Monthly::Month] 月(運用結果)
|
176
178
|
#
|
177
179
|
def rewrite_month(context:, month:, history:, operated_solar_term:)
|
178
180
|
operated_month = Monthly::OperatedMonth.new(
|
179
181
|
context: context,
|
180
182
|
month_label: month.month_label, first_day: month.first_day,
|
181
183
|
solar_terms: month.solar_terms, history: history, gengou: month.gengou,
|
182
|
-
operated_solar_term: operated_solar_term
|
184
|
+
operated_solar_term: operated_solar_term, meta: month.meta
|
183
185
|
)
|
184
186
|
|
185
187
|
operated_month.rewrite unless history.invalid?
|
186
188
|
|
187
189
|
operated_month
|
188
190
|
end
|
191
|
+
|
192
|
+
#
|
193
|
+
# メタ情報を更新する
|
194
|
+
#
|
195
|
+
# @param [Array<Base::Year>] years 完全範囲
|
196
|
+
#
|
197
|
+
def reset_meta(years: [])
|
198
|
+
months = []
|
199
|
+
years.each do |year|
|
200
|
+
months |= year.months
|
201
|
+
end
|
202
|
+
|
203
|
+
months.each_cons(2) do |last, current|
|
204
|
+
current.reset_meta(last: last)
|
205
|
+
end
|
206
|
+
end
|
189
207
|
end
|
190
208
|
end
|
191
209
|
end
|
@@ -19,10 +19,15 @@ module Zakuro
|
|
19
19
|
# @param [Context::Context] context 暦コンテキスト
|
20
20
|
# @param [Western::Calendar] start_date 開始日
|
21
21
|
# @param [Western::Calendar] last_date 終了日
|
22
|
+
# @param [True, False] operated 運用値設定
|
23
|
+
# @param [True, False] restored 運用値から計算値に戻すか
|
22
24
|
#
|
23
|
-
def initialize(context:,
|
24
|
-
|
25
|
-
scroll = Gengou::DatedScroll.new(
|
25
|
+
def initialize(context:, start_date: Western::Calendar.new,
|
26
|
+
last_date: Western::Calendar.new, operated: false, restored: false)
|
27
|
+
scroll = Gengou::DatedScroll.new(
|
28
|
+
start_date: start_date, last_date: last_date, operated: operated,
|
29
|
+
restored: restored
|
30
|
+
)
|
26
31
|
|
27
32
|
super(context: context, scroll: scroll, start_date: start_date, last_date: last_date)
|
28
33
|
end
|
@@ -24,7 +24,10 @@ module Zakuro
|
|
24
24
|
#
|
25
25
|
def initialize(context:, start_date: Western::Calendar.new,
|
26
26
|
last_date: Western::Calendar.new, years: [])
|
27
|
-
scroll = Gengou::DatedScroll.new(
|
27
|
+
scroll = Gengou::DatedScroll.new(
|
28
|
+
start_date: start_date, last_date: last_date, operated: true,
|
29
|
+
restored: false
|
30
|
+
)
|
28
31
|
super(context: context, scroll: scroll, years: years)
|
29
32
|
end
|
30
33
|
end
|
@@ -24,7 +24,9 @@ module Zakuro
|
|
24
24
|
# @param [String] last_name 終了元号名
|
25
25
|
#
|
26
26
|
def initialize(context:, start_name: INVALID_NAME, last_name: INVALID_NAME)
|
27
|
-
scroll = Gengou::NamedScroll.new(
|
27
|
+
scroll = Gengou::NamedScroll.new(
|
28
|
+
start_name: start_name, last_name: last_name, operated: false, restored: false
|
29
|
+
)
|
28
30
|
range = scroll.range
|
29
31
|
|
30
32
|
super(
|
@@ -26,7 +26,9 @@ module Zakuro
|
|
26
26
|
# @param [Array<Year>] years 年データ(完全範囲)
|
27
27
|
#
|
28
28
|
def initialize(context:, start_name: INVALID_NAME, last_name: INVALID_NAME, years: [])
|
29
|
-
scroll = Gengou::NamedScroll.new(
|
29
|
+
scroll = Gengou::NamedScroll.new(
|
30
|
+
start_name: start_name, last_name: last_name, operated: true
|
31
|
+
)
|
30
32
|
|
31
33
|
super(context: context, scroll: scroll, years: years)
|
32
34
|
end
|