zakuro 0.9.3 → 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 +8 -9
- 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/cycle/abstract_solar_term.rb +6 -0
- data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +2 -2
- data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +4 -2
- data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +1 -1
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +13 -7
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +18 -9
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +6 -2
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +5 -2
- data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +3 -3
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +12 -4
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +10 -4
- data/lib/zakuro/calculation/era/gengou/named_scroll.rb +5 -2
- 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 +38 -74
- data/lib/zakuro/calculation/monthly/operated_month.rb +7 -2
- data/lib/zakuro/calculation/option/dropped_date/location.rb +8 -1
- data/lib/zakuro/calculation/range/dated_full_range.rb +6 -3
- data/lib/zakuro/calculation/range/dated_operation_range.rb +2 -1
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +0 -2
- data/lib/zakuro/calculation/range/named_full_range.rb +1 -1
- 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/range.rb +8 -1
- data/lib/zakuro/calculation/summary/western/single.rb +10 -5
- 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 +35 -6
- 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 +8 -6
- 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 +8 -40
- 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 +3 -2
- 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 +40 -15
- data/lib/zakuro/condition.rb +0 -306
- data/lib/zakuro/era/japan/gengou/resource/type.rb +0 -356
- /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
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../context/option'
|
4
|
+
require_relative '../../../../result/data/option/dropped_date/option'
|
5
|
+
require_relative '../../../../result/data/solar_term'
|
6
|
+
|
7
|
+
require_relative '../../../option/dropped_date/location'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
# :nodoc:
|
12
|
+
module Calculation
|
13
|
+
# :nodoc:
|
14
|
+
module Summary
|
15
|
+
#
|
16
|
+
# Option オプション
|
17
|
+
#
|
18
|
+
module Option
|
19
|
+
#
|
20
|
+
# DroppedDate 没日
|
21
|
+
#
|
22
|
+
module DroppedDate
|
23
|
+
class << self
|
24
|
+
#
|
25
|
+
# 没日を取得する
|
26
|
+
#
|
27
|
+
# @param [Calculation::Monthly::Month] month 月情報(各暦のデータ型)
|
28
|
+
# @param [Calculation::Base::Day] day 日情報
|
29
|
+
#
|
30
|
+
# @return [Result::Data::Option::DroppedDate::Option] 没日
|
31
|
+
#
|
32
|
+
def get(month:, day:)
|
33
|
+
context = month.context
|
34
|
+
|
35
|
+
solar_term = month.solar_term_by_day(day: day.remainder.day)
|
36
|
+
|
37
|
+
remainder = day.remainder
|
38
|
+
|
39
|
+
dropped_date(
|
40
|
+
context: context, remainder: remainder, solar_term: solar_term
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
#
|
47
|
+
# 没日を求める
|
48
|
+
#
|
49
|
+
# @param [Context::Context] context 暦コンテキスト
|
50
|
+
# @param [Cycle::AbstractRemainder] remainder 当日和暦日
|
51
|
+
# @param [Cycle::AbstractSolarTerm] solar_terms 二十四節気
|
52
|
+
#
|
53
|
+
# @return [Result::Data::Option::DroppedDate::Option] 没日
|
54
|
+
#
|
55
|
+
def dropped_date(context:, remainder:, solar_term:)
|
56
|
+
option = Result::Data::Option::DroppedDate::Option.new
|
57
|
+
|
58
|
+
return option if remainder.invalid?
|
59
|
+
|
60
|
+
location = Calculation::Option::DroppedDate::Location.new(
|
61
|
+
context: context, solar_term: solar_term
|
62
|
+
)
|
63
|
+
|
64
|
+
return option if location.invalid?
|
65
|
+
|
66
|
+
return option unless location.exist?
|
67
|
+
|
68
|
+
dropped_date = location.get
|
69
|
+
|
70
|
+
dropped_date_option(
|
71
|
+
matched: remainder.day == dropped_date.day, location: location
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# 没日オプション値を生成する
|
77
|
+
#
|
78
|
+
# @param [True, False] matched 没日有無
|
79
|
+
# @param [Calculation::Option::DroppedDate::Location] location 没日位置
|
80
|
+
#
|
81
|
+
# @return [Result::Data::Option::DroppedDate::Option] 没日オプション値
|
82
|
+
#
|
83
|
+
def dropped_date_option(matched:, location:)
|
84
|
+
dropped_date = location.get
|
85
|
+
solar_term = location.solar_term
|
86
|
+
Result::Data::Option::DroppedDate::Option.new(
|
87
|
+
matched: matched,
|
88
|
+
calculation: Result::Data::Option::DroppedDate::Calculation.new(
|
89
|
+
remainder: dropped_date.format,
|
90
|
+
solar_term: Result::Data::SolarTerm.new(
|
91
|
+
index: solar_term.index,
|
92
|
+
remainder: solar_term.remainder.format
|
93
|
+
)
|
94
|
+
)
|
95
|
+
)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../context/option'
|
4
|
+
require_relative '../../../../result/data/option/vanished_date/option'
|
5
|
+
require_relative '../../../../result/data/solar_term'
|
6
|
+
|
7
|
+
require_relative '../../../option/vanished_date/location'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
# :nodoc:
|
12
|
+
module Calculation
|
13
|
+
# :nodoc:
|
14
|
+
module Summary
|
15
|
+
#
|
16
|
+
# Option オプション
|
17
|
+
#
|
18
|
+
module Option
|
19
|
+
#
|
20
|
+
# VanishedDate 滅日
|
21
|
+
#
|
22
|
+
module VanishedDate
|
23
|
+
class << self
|
24
|
+
#
|
25
|
+
# 滅日を取得する
|
26
|
+
#
|
27
|
+
# @param [Calculation::Monthly::Month] month 月情報(各暦のデータ型)
|
28
|
+
# @param [Calculation::Base::Day] day 日情報
|
29
|
+
#
|
30
|
+
# @return [Result::Data::Option::VanishedDate::Option] 滅日オプション値
|
31
|
+
#
|
32
|
+
def get(month:, day:)
|
33
|
+
context = month.context
|
34
|
+
|
35
|
+
remainder = day.remainder
|
36
|
+
average_remainder = month.first_day.average_remainder
|
37
|
+
# p "remainder: #{remainder.format}"
|
38
|
+
# p "last_average_remainder: #{month.meta.last_average_remainder.format}"
|
39
|
+
|
40
|
+
if day.number == 1
|
41
|
+
option = vanished_date(
|
42
|
+
context: context, remainder: remainder,
|
43
|
+
average_remainder: month.meta.last_average_remainder
|
44
|
+
)
|
45
|
+
|
46
|
+
return option if option.matched
|
47
|
+
end
|
48
|
+
|
49
|
+
vanished_date(
|
50
|
+
context: context, remainder: remainder, average_remainder: average_remainder
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
#
|
57
|
+
# 滅日を求める
|
58
|
+
#
|
59
|
+
# @param [Context::Context] context 暦コンテキスト
|
60
|
+
# @param [Cycle::AbstractRemainder] remainder 当日和暦日
|
61
|
+
# @param [Cycle::AbstractRemainder] average_remainder 経朔
|
62
|
+
#
|
63
|
+
# @return [Result::Data::Option::VanishedDate::Option] 滅日オプション値
|
64
|
+
#
|
65
|
+
def vanished_date(context:, remainder:, average_remainder:)
|
66
|
+
return Result::Data::Option::VanishedDate::Option.new if average_remainder.invalid?
|
67
|
+
|
68
|
+
location = Calculation::Option::VanishedDate::Location.new(
|
69
|
+
context: context, average_remainder: average_remainder
|
70
|
+
)
|
71
|
+
|
72
|
+
return Result::Data::Option::VanishedDate::Option.new if location.invalid?
|
73
|
+
|
74
|
+
unless location.exist?
|
75
|
+
# 結果確認のため経朔だけは設定する
|
76
|
+
return Result::Data::Option::VanishedDate::Option.new(
|
77
|
+
calculation: Result::Data::Option::VanishedDate::Calculation.new(
|
78
|
+
average_remainder: average_remainder
|
79
|
+
)
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
vanished_date = location.get
|
84
|
+
|
85
|
+
vanished_date_option(matched: remainder.day == vanished_date.day, location: location)
|
86
|
+
end
|
87
|
+
|
88
|
+
#
|
89
|
+
# 滅日オプション値を生成する
|
90
|
+
#
|
91
|
+
# @param [True, False] matched 滅日有無
|
92
|
+
# @param [Calculation::Option::VanishedDate::Location] location 滅日位置
|
93
|
+
#
|
94
|
+
# @return [Result::Data::Option::VanishedDate::Option] 滅日オプション値
|
95
|
+
#
|
96
|
+
def vanished_date_option(matched:, location:)
|
97
|
+
vanished_date = location.get
|
98
|
+
Result::Data::Option::VanishedDate::Option.new(
|
99
|
+
matched: matched,
|
100
|
+
calculation: Result::Data::Option::VanishedDate::Calculation.new(
|
101
|
+
remainder: vanished_date.format,
|
102
|
+
average_remainder: location.average_remainder
|
103
|
+
)
|
104
|
+
)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -1,12 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../../../context/option'
|
4
|
-
require_relative '../../../result/data/option/dropped_date/option'
|
5
|
-
require_relative '../../../result/data/solar_term'
|
6
|
-
require_relative '../../../result/data/option/vanished_date/option'
|
7
4
|
|
8
|
-
require_relative '
|
9
|
-
require_relative '
|
5
|
+
require_relative './option/dropped_date'
|
6
|
+
require_relative './option/vanished_date'
|
10
7
|
|
11
8
|
# :nodoc:
|
12
9
|
module Zakuro
|
@@ -28,153 +25,23 @@ module Zakuro
|
|
28
25
|
# @return [Hash<String, Result::Data::Option::AbstractOption>] オプション結果
|
29
26
|
#
|
30
27
|
def create(month:, day:)
|
31
|
-
# TODO: refactor
|
32
|
-
|
33
28
|
options = {}
|
34
29
|
context = month.context
|
35
30
|
|
36
31
|
if context.option.dropped_date?
|
37
|
-
|
32
|
+
option = DroppedDate.get(month: month, day: day)
|
38
33
|
|
39
|
-
remainder = day.remainder
|
40
|
-
option = dropped_date(
|
41
|
-
context: context, remainder: remainder, solar_term: solar_term
|
42
|
-
)
|
43
34
|
options[Context::Option::DROPPED_DATE_KEY] = option
|
44
35
|
end
|
45
36
|
|
46
|
-
# TODO: refactor
|
47
37
|
if context.option.vanished_date?
|
48
|
-
|
49
|
-
average_remainder = month.first_day.average_remainder
|
50
|
-
# p "remainder: #{remainder.format}"
|
51
|
-
# p "last_average_remainder: #{month.meta.last_average_remainder.format}"
|
52
|
-
|
53
|
-
if day.number == 1
|
54
|
-
option = vanished_date(
|
55
|
-
context: context, remainder: remainder,
|
56
|
-
average_remainder: month.meta.last_average_remainder
|
57
|
-
)
|
58
|
-
options[Context::Option::VANISHED_DATE_KEY] = option
|
59
|
-
|
60
|
-
return options if option.matched
|
61
|
-
end
|
38
|
+
option = VanishedDate.get(month: month, day: day)
|
62
39
|
|
63
|
-
option = vanished_date(
|
64
|
-
context: context, remainder: remainder, average_remainder: average_remainder
|
65
|
-
)
|
66
40
|
options[Context::Option::VANISHED_DATE_KEY] = option
|
67
41
|
end
|
68
42
|
|
69
43
|
options
|
70
44
|
end
|
71
|
-
|
72
|
-
private
|
73
|
-
|
74
|
-
#
|
75
|
-
# 没日を求める
|
76
|
-
#
|
77
|
-
# @param [Context::Context] context 暦コンテキスト
|
78
|
-
# @param [Cycle::AbstractRemainder] remainder 当日和暦日
|
79
|
-
# @param [Cycle::AbstractSolarTerm] solar_terms 二十四節気
|
80
|
-
#
|
81
|
-
# @return [Result::Data::Option::DroppedDate::Option] 没日
|
82
|
-
#
|
83
|
-
def dropped_date(context:, remainder:, solar_term:)
|
84
|
-
option = Result::Data::Option::DroppedDate::Option.new
|
85
|
-
|
86
|
-
return option if remainder.invalid?
|
87
|
-
|
88
|
-
location = Calculation::Option::DroppedDate::Location.new(
|
89
|
-
context: context, solar_term: solar_term
|
90
|
-
)
|
91
|
-
|
92
|
-
return option if location.invalid?
|
93
|
-
|
94
|
-
return option unless location.exist?
|
95
|
-
|
96
|
-
dropped_date = location.get
|
97
|
-
|
98
|
-
dropped_date_option(
|
99
|
-
matched: remainder.day == dropped_date.day, location: location
|
100
|
-
)
|
101
|
-
end
|
102
|
-
|
103
|
-
#
|
104
|
-
# 没日オプション値を生成する
|
105
|
-
#
|
106
|
-
# @param [True, False] matched 没日有無
|
107
|
-
# @param [Calculation::Option::DroppedDate::Location] location 没日位置
|
108
|
-
#
|
109
|
-
# @return [Result::Data::Option::DroppedDate::Option] 没日オプション値
|
110
|
-
#
|
111
|
-
def dropped_date_option(matched:, location:)
|
112
|
-
dropped_date = location.get
|
113
|
-
solar_term = location.solar_term
|
114
|
-
Result::Data::Option::DroppedDate::Option.new(
|
115
|
-
matched: matched,
|
116
|
-
calculation: Result::Data::Option::DroppedDate::Calculation.new(
|
117
|
-
remainder: dropped_date.format,
|
118
|
-
solar_term: Result::Data::SolarTerm.new(
|
119
|
-
index: solar_term.index,
|
120
|
-
remainder: solar_term.remainder.format
|
121
|
-
)
|
122
|
-
)
|
123
|
-
)
|
124
|
-
end
|
125
|
-
|
126
|
-
#
|
127
|
-
# 滅日を求める
|
128
|
-
#
|
129
|
-
# @param [Context::Context] context 暦コンテキスト
|
130
|
-
# @param [Cycle::AbstractRemainder] remainder 当日和暦日
|
131
|
-
# @param [Cycle::AbstractRemainder] average_remainder 経朔
|
132
|
-
#
|
133
|
-
# @return [Result::Data::Option::VanishedDate::Option] 滅日オプション値
|
134
|
-
#
|
135
|
-
def vanished_date(context:, remainder:, average_remainder:)
|
136
|
-
return Result::Data::Option::VanishedDate::Option.new if average_remainder.invalid?
|
137
|
-
|
138
|
-
location = Calculation::Option::VanishedDate::Location.new(
|
139
|
-
context: context, average_remainder: average_remainder
|
140
|
-
)
|
141
|
-
|
142
|
-
return Result::Data::Option::VanishedDate::Option.new if location.invalid?
|
143
|
-
|
144
|
-
unless location.exist?
|
145
|
-
# 結果確認のため経朔だけは設定する
|
146
|
-
return Result::Data::Option::VanishedDate::Option.new(
|
147
|
-
calculation: Result::Data::Option::VanishedDate::Calculation.new(
|
148
|
-
average_remainder: average_remainder
|
149
|
-
)
|
150
|
-
)
|
151
|
-
end
|
152
|
-
|
153
|
-
vanished_date = location.get
|
154
|
-
|
155
|
-
vanished_date_option(
|
156
|
-
matched: remainder.day == vanished_date.day, location: location
|
157
|
-
)
|
158
|
-
end
|
159
|
-
|
160
|
-
#
|
161
|
-
# 滅日オプション値を生成する
|
162
|
-
#
|
163
|
-
# @param [True, False] matched 滅日有無
|
164
|
-
# @param [Calculation::Option::VanishedDate::Location] location 滅日位置
|
165
|
-
#
|
166
|
-
# @return [Result::Data::Option::VanishedDate::Option] 滅日オプション値
|
167
|
-
#
|
168
|
-
def vanished_date_option(matched:, location:)
|
169
|
-
vanished_date = location.get
|
170
|
-
Result::Data::Option::VanishedDate::Option.new(
|
171
|
-
matched: matched,
|
172
|
-
calculation: Result::Data::Option::VanishedDate::Calculation.new(
|
173
|
-
remainder: vanished_date.format,
|
174
|
-
average_remainder: location.average_remainder
|
175
|
-
)
|
176
|
-
)
|
177
|
-
end
|
178
45
|
end
|
179
46
|
end
|
180
47
|
end
|
@@ -48,8 +48,8 @@ module Zakuro
|
|
48
48
|
)
|
49
49
|
|
50
50
|
list = create_list(
|
51
|
-
context: context,
|
52
|
-
operated_years: operated_years, years: years
|
51
|
+
context: context, range: range,
|
52
|
+
operated_years: operated_years, years: years
|
53
53
|
)
|
54
54
|
|
55
55
|
Result::Range.new(list: list)
|
@@ -82,14 +82,13 @@ module Zakuro
|
|
82
82
|
# 1日検索結果リストを生成する
|
83
83
|
#
|
84
84
|
# @param [Context::Context] context 暦コンテキスト
|
85
|
+
# @param [SpecifiedRange] range 特定範囲
|
85
86
|
# @param [Array<Base::OperatedYear>] operated_years 運用結果範囲
|
86
87
|
# @param [Array<Base::Year>] years 完全範囲
|
87
|
-
# @param [SpecifiedRange] range 特定範囲
|
88
88
|
#
|
89
89
|
# @return [Array<Result::Single>] 結果リスト
|
90
90
|
#
|
91
|
-
def create_list(context:, operated_years: [], years: []
|
92
|
-
range:)
|
91
|
+
def create_list(context:, range:, operated_years: [], years: [])
|
93
92
|
western_start_date = range.start_date.day.western_date
|
94
93
|
western_last_date = range.last_date.day.western_date
|
95
94
|
|
@@ -35,6 +35,7 @@ module Zakuro
|
|
35
35
|
years = get_full_range_years(
|
36
36
|
context: context, start_date: start_date, last_date: last_date
|
37
37
|
)
|
38
|
+
|
38
39
|
operated_years = get_operation_range_years(
|
39
40
|
context: context, years: years, start_date: start_date, last_date: last_date
|
40
41
|
)
|
@@ -66,8 +67,14 @@ module Zakuro
|
|
66
67
|
#
|
67
68
|
def get_full_range_years(context:, start_date: Western::Calendar.new,
|
68
69
|
last_date: Western::Calendar.new)
|
70
|
+
# 年情報の再計算
|
71
|
+
# * 元号開始日に計算値と運用値のズレが見られる場合、年情報の範囲が異なる場合がある
|
72
|
+
# * 例:0781-03-01(計算値は前の元号の「宝亀」を含めるが、運用値では含まない)
|
73
|
+
#
|
74
|
+
# 運用値の範囲で日付検索するが、元号開始日は計算値のままで取る
|
69
75
|
full_range = Calculation::Range::DatedFullRange.new(
|
70
|
-
context: context, start_date: start_date, last_date: last_date
|
76
|
+
context: context, start_date: start_date, last_date: last_date,
|
77
|
+
operated: true, restored: true
|
71
78
|
)
|
72
79
|
full_range.get
|
73
80
|
end
|
@@ -4,10 +4,10 @@ require_relative '../../range/dated_operation_range'
|
|
4
4
|
|
5
5
|
require_relative '../../range/dated_full_range'
|
6
6
|
|
7
|
-
require_relative './specifier/single_day'
|
8
|
-
|
9
7
|
require_relative '../internal/operation'
|
10
8
|
|
9
|
+
require_relative './specifier/single_day'
|
10
|
+
|
11
11
|
# :nodoc:
|
12
12
|
module Zakuro
|
13
13
|
# :nodoc:
|
@@ -53,8 +53,13 @@ module Zakuro
|
|
53
53
|
# @return [Array<Calculation::Base::Year>] 完全範囲
|
54
54
|
#
|
55
55
|
def get_full_range_years(context:, date: Western::Calendar.new)
|
56
|
+
# 年情報の再計算
|
57
|
+
# * 元号開始日に計算値と運用値のズレが見られる場合、年情報の範囲が異なる場合がある
|
58
|
+
# * 例:0781-03-01(計算値は前の元号の「宝亀」を含めるが、運用値では含まない)
|
59
|
+
#
|
60
|
+
# 運用値の範囲で日付検索するが、元号開始日は計算値のままで取る
|
56
61
|
full_range = Calculation::Range::DatedFullRange.new(
|
57
|
-
context: context, start_date: date
|
62
|
+
context: context, start_date: date, operated: true, restored: true
|
58
63
|
)
|
59
64
|
full_range.get
|
60
65
|
end
|
@@ -93,12 +98,12 @@ module Zakuro
|
|
93
98
|
end
|
94
99
|
|
95
100
|
#
|
96
|
-
#
|
101
|
+
# 運用情報を取得する
|
97
102
|
#
|
98
103
|
# @param [Array<Calculation::Base::Year>] years 完全範囲
|
99
104
|
# @param [Western::Calendar] date 西暦日
|
100
105
|
#
|
101
|
-
# @return [
|
106
|
+
# @return [Result::Operation] 運用情報
|
102
107
|
#
|
103
108
|
def get_operation(years:, date: Western::Calendar.new)
|
104
109
|
calc_date = Specifier::SingleDay.get(
|
@@ -37,11 +37,11 @@ module Zakuro
|
|
37
37
|
|
38
38
|
# @return [Hash<String, String>] 関連
|
39
39
|
CLASSES = {
|
40
|
-
'remainder' => 'Zakuro::$VERSION::Cycle::Remainder',
|
41
|
-
'solar_term' => 'Zakuro::$VERSION::Cycle::SolarTerm',
|
42
|
-
'annual_range' => 'Zakuro::$VERSION::Range::AnnualRange',
|
43
|
-
'dropped_date_parameter' => 'Zakuro::$VERSION::Option::DroppedDate::Parameter',
|
44
|
-
'vanished_date_parameter' => 'Zakuro::$VERSION::Option::VanishedDate::Parameter'
|
40
|
+
'remainder' => 'Zakuro::Version::$VERSION::Cycle::Remainder',
|
41
|
+
'solar_term' => 'Zakuro::Version::$VERSION::Cycle::SolarTerm',
|
42
|
+
'annual_range' => 'Zakuro::Version::$VERSION::Range::AnnualRange',
|
43
|
+
'dropped_date_parameter' => 'Zakuro::Version::$VERSION::Option::DroppedDate::Parameter',
|
44
|
+
'vanished_date_parameter' => 'Zakuro::Version::$VERSION::Option::VanishedDate::Parameter'
|
45
45
|
}.freeze
|
46
46
|
|
47
47
|
#
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../../
|
3
|
+
require_relative '../../tool/typeconv'
|
4
4
|
|
5
5
|
# :nodoc:
|
6
6
|
module Zakuro
|
@@ -104,10 +104,10 @@ module Zakuro
|
|
104
104
|
|
105
105
|
Calendar.new(
|
106
106
|
gengou: matched[1],
|
107
|
-
year:
|
107
|
+
year: Tool::Typeconv.to_i(text: matched[2], default: INVALID),
|
108
108
|
leaped: matched[3] ? true : false,
|
109
|
-
month:
|
110
|
-
day:
|
109
|
+
month: Tool::Typeconv.to_i(text: matched[4], default: INVALID),
|
110
|
+
day: Tool::Typeconv.to_i(text: matched[5], default: INVALID)
|
111
111
|
)
|
112
112
|
end
|
113
113
|
|
@@ -85,7 +85,7 @@ module Zakuro
|
|
85
85
|
def connect(list: []) # rubocop:disable Metrics/MethodLength
|
86
86
|
result = []
|
87
87
|
list.each do |linear_gengou|
|
88
|
-
if result.
|
88
|
+
if result.empty?
|
89
89
|
result.push(linear_gengou)
|
90
90
|
next
|
91
91
|
end
|
@@ -145,7 +145,7 @@ module Zakuro
|
|
145
145
|
)
|
146
146
|
end
|
147
147
|
|
148
|
-
def shave_gengou(this:, other:)
|
148
|
+
def shave_gengou(this:, other:)
|
149
149
|
start = this.start_date
|
150
150
|
last = this.last_date
|
151
151
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative '../../../western/calendar'
|
4
4
|
|
5
|
-
require_relative '
|
5
|
+
require_relative '../../type/base/gengou_set'
|
6
6
|
|
7
7
|
# :nodoc:
|
8
8
|
module Zakuro
|
@@ -33,7 +33,7 @@ module Zakuro
|
|
33
33
|
# @param [Resource::Gengou] gengou 元号
|
34
34
|
#
|
35
35
|
def initialize(start_date: Western::Calendar.new, last_date: Western::Calendar.new,
|
36
|
-
gengou:
|
36
|
+
gengou: Type::Base::Gengou.new)
|
37
37
|
@gengou = gengou
|
38
38
|
@start_date = start_date.invalid? ? native_start_date : start_date
|
39
39
|
@last_date = last_date.invalid? ? native_last_date : last_date
|
@@ -34,15 +34,20 @@ module Zakuro
|
|
34
34
|
# @param [Western::Calendar] start_date 開始日
|
35
35
|
# @param [Western::Calendar] last_date 終了日
|
36
36
|
# @param [True, False] operated 運用値設定
|
37
|
+
# @param [True, False] restored 運用値から計算値に戻すか
|
37
38
|
#
|
38
39
|
# @return [Array<LinearGengou>] 元号
|
39
40
|
#
|
40
41
|
def get(line: FIRST_LINE,
|
41
42
|
start_date: Western::Calendar.new, last_date: Western::Calendar.new,
|
42
|
-
operated: false)
|
43
|
-
|
43
|
+
operated: false, restored: false)
|
44
44
|
if operated
|
45
|
-
|
45
|
+
result = OPERATED_SUMMARY.get(
|
46
|
+
line: line, start_date: start_date, last_date: last_date
|
47
|
+
)
|
48
|
+
return result unless restored
|
49
|
+
|
50
|
+
return restore(line: line, list: result)
|
46
51
|
end
|
47
52
|
|
48
53
|
SUMMARY.get(line: line, start_date: start_date, last_date: last_date)
|
@@ -51,17 +56,41 @@ module Zakuro
|
|
51
56
|
#
|
52
57
|
# 指定した範囲内の元号を取得する(元号名)
|
53
58
|
#
|
54
|
-
# @param [Integer] line 行
|
55
59
|
# @param [String] name 元号名
|
60
|
+
# @param [Integer] line 行
|
56
61
|
# @param [True, False] operated 運用値設定
|
62
|
+
# @param [True, False] restored 運用値から計算値に戻すか
|
57
63
|
#
|
58
64
|
# @return [Array<LinearGengou>] 元号
|
59
65
|
#
|
60
|
-
def get_by_name(line: FIRST_LINE,
|
61
|
-
|
66
|
+
def get_by_name(name:, line: FIRST_LINE, operated: false, restored: false)
|
67
|
+
if operated
|
68
|
+
result = OPERATED_SUMMARY.get_by_name(line: line, name: name)
|
69
|
+
return result unless restored
|
70
|
+
|
71
|
+
return restore(line: line, list: result)
|
72
|
+
end
|
62
73
|
|
63
74
|
SUMMARY.get_by_name(line: line, name: name)
|
64
75
|
end
|
76
|
+
|
77
|
+
#
|
78
|
+
# 運用値から計算値に戻す
|
79
|
+
#
|
80
|
+
# @param [Integer] line 行
|
81
|
+
# @param [Array<LinearGengou>] list 元号
|
82
|
+
#
|
83
|
+
# @return [Array<LinearGengou>] 元号
|
84
|
+
#
|
85
|
+
def restore(line: FIRST_LINE, list: [])
|
86
|
+
result = []
|
87
|
+
list.each do |gengou|
|
88
|
+
calc = SUMMARY.get_by_name(line: line, name: gengou.name)
|
89
|
+
result |= calc
|
90
|
+
end
|
91
|
+
|
92
|
+
result
|
93
|
+
end
|
65
94
|
end
|
66
95
|
end
|
67
96
|
end
|