zakuro 0.7.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -13
- data/VERSION +1 -1
- data/doc/dropped_date.md +93 -0
- data/doc/error.md +45 -0
- data/doc/operation/csv/month.csv +100 -79
- data/doc/operation/operation.xlsx +0 -0
- data/lib/zakuro/calculation/base/day.rb +52 -0
- data/lib/zakuro/calculation/base/gengou.rb +5 -5
- data/lib/zakuro/calculation/base/linear_gengou.rb +5 -5
- data/lib/zakuro/calculation/base/operated_year.rb +26 -24
- data/lib/zakuro/calculation/base/year.rb +7 -7
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +55 -47
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +28 -24
- data/lib/zakuro/calculation/cycle/zodiac.rb +22 -20
- data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +38 -29
- data/lib/zakuro/calculation/era/gengou/internal/connector.rb +4 -4
- data/lib/zakuro/calculation/era/gengou/internal/counter.rb +16 -16
- data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +74 -72
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +16 -16
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +58 -35
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +3 -3
- data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +111 -113
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +6 -6
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +7 -9
- data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +22 -20
- data/lib/zakuro/calculation/era/version/internal/crawler.rb +39 -22
- data/lib/zakuro/calculation/era/version/version.rb +12 -10
- data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +13 -9
- data/lib/zakuro/calculation/monthly/const.rb +18 -0
- data/lib/zakuro/calculation/monthly/initialized_month.rb +40 -38
- data/lib/zakuro/calculation/monthly/month.rb +17 -17
- data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
- data/lib/zakuro/calculation/monthly/operated_month.rb +37 -86
- data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
- data/lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb +44 -0
- data/lib/zakuro/calculation/option/dropped_date/location.rb +135 -0
- data/lib/zakuro/calculation/range/abstract_full_range.rb +40 -25
- data/lib/zakuro/calculation/range/abstract_operation_range.rb +111 -109
- data/lib/zakuro/calculation/range/dated_full_range.rb +1 -1
- data/lib/zakuro/calculation/range/dated_operation_range.rb +1 -1
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
- data/lib/zakuro/calculation/range/named_full_range.rb +1 -1
- data/lib/zakuro/calculation/range/named_operation_range.rb +1 -1
- data/lib/zakuro/calculation/range/operated_solar_term.rb +220 -0
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +32 -29
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +115 -117
- data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +1 -1
- data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +48 -46
- data/lib/zakuro/calculation/stella/solar/abstract_average.rb +31 -26
- data/lib/zakuro/calculation/stella/solar/abstract_location.rb +7 -5
- data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
- data/lib/zakuro/calculation/summary/internal/day.rb +42 -0
- data/lib/zakuro/calculation/summary/internal/month.rb +32 -11
- data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
- data/lib/zakuro/calculation/summary/internal/option.rb +101 -0
- data/lib/zakuro/calculation/summary/japan/range.rb +145 -118
- data/lib/zakuro/calculation/summary/japan/single.rb +87 -87
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +57 -50
- data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
- data/lib/zakuro/calculation/summary/western/range.rb +95 -92
- data/lib/zakuro/calculation/summary/western/single.rb +78 -76
- data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +123 -119
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +63 -56
- data/lib/zakuro/calculation/type/old_float.rb +2 -2
- data/lib/zakuro/calculation/type/optional.rb +46 -0
- data/lib/zakuro/condition.rb +142 -92
- data/lib/zakuro/context/context.rb +44 -0
- data/lib/zakuro/context/option.rb +119 -0
- data/lib/zakuro/context/version_class_resolver.rb +112 -0
- data/lib/zakuro/era/japan/calendar.rb +35 -33
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +8 -4
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +117 -118
- data/lib/zakuro/era/japan/gengou/alignment/line.rb +7 -5
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +20 -14
- data/lib/zakuro/era/japan/gengou/alignment.rb +27 -25
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +51 -34
- data/lib/zakuro/era/japan/gengou/resource/type.rb +45 -37
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +34 -32
- data/lib/zakuro/era/japan/gengou.rb +28 -26
- data/lib/zakuro/era/japan/version.rb +18 -16
- data/lib/zakuro/era/western/calendar.rb +104 -88
- data/lib/zakuro/exception/case/pattern.rb +39 -3
- data/lib/zakuro/exception/case/preset.rb +2 -2
- data/lib/zakuro/exception/exception.rb +17 -15
- data/lib/zakuro/exception/zakuro_error.rb +19 -1
- data/lib/zakuro/gateway/locale/date.rb +2 -2
- data/lib/zakuro/gateway/locale/range.rb +3 -3
- data/lib/zakuro/gateway/range.rb +3 -3
- data/lib/zakuro/gateway/single.rb +14 -3
- data/lib/zakuro/merchant.rb +79 -9
- data/lib/zakuro/operation/month/parser.rb +252 -249
- data/lib/zakuro/operation/month/type.rb +17 -8
- data/lib/zakuro/operation/month/validator.rb +148 -144
- data/lib/zakuro/operation/operation.rb +38 -36
- data/lib/zakuro/operation/yaml/month.yaml +955 -281
- data/lib/zakuro/output/response.rb +107 -141
- data/lib/zakuro/result/data/option/abstract_option.rb +37 -0
- data/lib/zakuro/result/data/option/dropped_date/calculation.rb +47 -0
- data/lib/zakuro/result/data/option/dropped_date/option.rb +47 -0
- data/lib/zakuro/result/data/option/dropped_date/solar_term.rb +48 -0
- data/lib/zakuro/result/data/single_day.rb +9 -1
- data/lib/zakuro/result/operation/month/annotation.rb +2 -2
- data/lib/zakuro/result/operation/month/history.rb +2 -2
- data/lib/zakuro/result/operation/month.rb +31 -0
- data/lib/zakuro/result/operation.rb +39 -0
- data/lib/zakuro/result/result.rb +3 -3
- data/lib/zakuro/tools/stringifier.rb +67 -42
- data/lib/zakuro/tools/typeconv.rb +17 -15
- data/lib/zakuro/tools/typeof.rb +15 -13
- data/lib/zakuro/version/daien/cycle/remainder.rb +2 -2
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
- data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -37
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -47
- data/lib/zakuro/version/daien/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +22 -20
- data/lib/zakuro/version/daien/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/daien/stella/solar/average.rb +53 -51
- data/lib/zakuro/version/daien/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/daien/stella/solar/value.rb +13 -11
- data/lib/zakuro/version/genka/cycle/remainder.rb +4 -4
- data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
- data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/genka/range/annual_range.rb +48 -44
- data/lib/zakuro/version/genka/stella/origin/first_term.rb +30 -28
- data/lib/zakuro/version/genka/stella/origin/january.rb +22 -20
- data/lib/zakuro/version/gihou/cycle/remainder.rb +2 -2
- data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +9 -9
- data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -37
- data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -47
- data/lib/zakuro/version/gihou/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +24 -22
- data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/gihou/stella/solar/average.rb +52 -50
- data/lib/zakuro/version/gihou/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/gihou/stella/solar/value.rb +13 -11
- data/lib/zakuro/version/senmyou/const/remainder.rb +7 -1
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +37 -2
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +10 -10
- data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +33 -0
- data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -36
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -34
- data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +22 -20
- data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +52 -50
- data/lib/zakuro/version/senmyou/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/senmyou/stella/solar/value.rb +13 -11
- metadata +27 -7
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -218
- data/lib/zakuro/result/operation/month/bundle.rb +0 -36
- data/lib/zakuro/result/operation/operation.rb +0 -44
- data/lib/zakuro/version/context.rb +0 -44
- data/lib/zakuro/version/version_class_resolver.rb +0 -74
@@ -13,20 +13,22 @@ module Zakuro
|
|
13
13
|
# AverageNovember 11月経
|
14
14
|
#
|
15
15
|
module AverageNovember
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
16
|
+
class << self
|
17
|
+
#
|
18
|
+
# 11月経朔(冬至が含まれる月の1日)を求める
|
19
|
+
#
|
20
|
+
# @param [Integer] western_year 西暦年
|
21
|
+
#
|
22
|
+
# @return [Remainder] 11月経朔
|
23
|
+
#
|
24
|
+
def get(western_year:)
|
25
|
+
# 冬至
|
26
|
+
winter_solstice = WinterSolstice.get(western_year: western_year)
|
27
|
+
# 天正閏余
|
28
|
+
lunar_age = LunarAge.get(western_year: western_year)
|
28
29
|
|
29
|
-
|
30
|
+
winter_solstice.sub(lunar_age)
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -28,33 +28,35 @@ module Zakuro
|
|
28
28
|
|
29
29
|
# :reek:TooManyStatements { max_statements: 7 }
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
31
|
+
class << self
|
32
|
+
#
|
33
|
+
# 対象年の天正閏余(冬至より前にある11月経朔との差 = 月齢)を算出する
|
34
|
+
# 太陽と月の運動による補正値を算出し、その補正結果を返す
|
35
|
+
#
|
36
|
+
# @param [Integer] western_year 西暦年
|
37
|
+
#
|
38
|
+
# @return [Remainder] 天正閏余
|
39
|
+
#
|
40
|
+
def get(western_year:)
|
41
|
+
# 積年の開始から対象年までの年数
|
42
|
+
total = TOTAL_YEAR + western_year - BEGIN_YEAR
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
# 12朔望月に対する1年の余り(単位:分)
|
45
|
+
remainder_minute = YEAR - (SYNODIC_MONTH * 12)
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
# 朔望月に含まれなかった余り(単位:年)
|
48
|
+
remainder_year = total % SYNODIC_MONTH
|
48
49
|
|
49
|
-
|
50
|
+
LOGGER.debug("[01]: #{remainder_year}")
|
50
51
|
|
51
|
-
|
52
|
-
|
52
|
+
# 天正閏余
|
53
|
+
lunar_age = remainder_minute * remainder_year % SYNODIC_MONTH
|
53
54
|
|
54
|
-
|
55
|
+
LOGGER.debug("[02]: #{lunar_age}")
|
55
56
|
|
56
|
-
|
57
|
-
|
57
|
+
# 大余・小余に変換する
|
58
|
+
Cycle::Remainder.new(total: lunar_age)
|
59
|
+
end
|
58
60
|
end
|
59
61
|
end
|
60
62
|
end
|
@@ -28,26 +28,28 @@ module Zakuro
|
|
28
28
|
|
29
29
|
# :reek:TooManyStatements { max_statements: 6 }
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
31
|
+
class << self
|
32
|
+
#
|
33
|
+
# 対象年の前年の冬至を求める
|
34
|
+
#
|
35
|
+
# @param [Integer] western_year 西暦年
|
36
|
+
#
|
37
|
+
# @return [Remainder] 前年の冬至
|
38
|
+
#
|
39
|
+
def get(western_year:)
|
40
|
+
# 積年の開始から対象年までの年数
|
41
|
+
total = TOTAL_YEAR + western_year - BEGIN_YEAR
|
42
|
+
remainder_year = total % SIXTY_DAYS
|
43
|
+
|
44
|
+
LOGGER.debug("[01]:#{remainder_year}")
|
45
|
+
|
46
|
+
# 通余を使う
|
47
|
+
winter_solstice_minute = (remainder_year * REMAINDER_ALL_YEAR) % SIXTY_DAYS
|
48
|
+
|
49
|
+
LOGGER.debug("[02]:#{winter_solstice_minute}")
|
50
|
+
|
51
|
+
Cycle::Remainder.new(total: winter_solstice_minute)
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
@@ -76,16 +76,18 @@ module Zakuro
|
|
76
76
|
taisetsu: Row.new(stack: -176.0, per_term: +10.9010, per_day: +0.1886) # 大雪(たいせつ)
|
77
77
|
}.freeze
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
79
|
+
class << self
|
80
|
+
#
|
81
|
+
# 24気損益眺朒(ちょうじく)数の行データを特定する
|
82
|
+
#
|
83
|
+
# @param [Integer] index 連番(二十四節気)
|
84
|
+
#
|
85
|
+
# @return [Row] 行データ
|
86
|
+
#
|
87
|
+
def specify(index:)
|
88
|
+
key = Cycle::SolarTerm::ORDER[index]
|
89
|
+
Adjustment::MAP[key].clone
|
90
|
+
end
|
89
91
|
end
|
90
92
|
end
|
91
93
|
end
|
@@ -26,7 +26,7 @@ module Zakuro
|
|
26
26
|
# @param [Integer] western_year 西暦年
|
27
27
|
#
|
28
28
|
def initialize(western_year:)
|
29
|
-
solar_term =
|
29
|
+
solar_term = self.class.first_solar_term(western_year: western_year)
|
30
30
|
super(solar_term: solar_term)
|
31
31
|
end
|
32
32
|
|
@@ -41,56 +41,58 @@ module Zakuro
|
|
41
41
|
super(annual_range: annual_range)
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
44
|
+
class << self
|
45
|
+
#
|
46
|
+
# 計算開始する二十四節気を求める
|
47
|
+
#
|
48
|
+
# @param [Integer] western_year 西暦年
|
49
|
+
#
|
50
|
+
# @return [SolarTerm] 二十四節気
|
51
|
+
#
|
52
|
+
def first_solar_term(western_year:)
|
53
|
+
# 天正冬至
|
54
|
+
winter_solstice = Origin::WinterSolstice.get(western_year: western_year)
|
55
|
+
|
56
|
+
# 二十四節気(冬至)
|
57
|
+
solar_term = Cycle::SolarTerm.new(index: 0, remainder: winter_solstice)
|
58
|
+
|
59
|
+
first_solar_term_index = calc_first_solar_term_index(western_year: western_year)
|
60
|
+
|
61
|
+
# 対象の二十四節気まで戻す
|
62
|
+
solar_term.prev_by_index(first_solar_term_index)
|
63
|
+
|
64
|
+
solar_term
|
65
|
+
end
|
66
|
+
|
67
|
+
# :reek:TooManyStatements { max_statements: 6 }
|
68
|
+
|
69
|
+
#
|
70
|
+
# 計算開始する二十四節気番号を求める
|
71
|
+
#
|
72
|
+
# * 前提として入定気は冬至の手前にある
|
73
|
+
# * 例えば、定気が大雪であれば入定気は大雪の範囲内にある
|
74
|
+
# * 入定気は、定気の開始位置に重複しない限り、常に定気より後にある
|
75
|
+
# * 基本的に定気の一つ前から起算すれば、当時から求めた11月(閏10/閏11月)に二十四節気を割り当てられる
|
76
|
+
#
|
77
|
+
# @param [Integer] western_year 西暦年
|
78
|
+
#
|
79
|
+
# @return [Integer] 二十四節気番号
|
80
|
+
#
|
81
|
+
def calc_first_solar_term_index(western_year:)
|
82
|
+
# 天正閏余
|
83
|
+
lunar_age = Origin::LunarAge.get(western_year: western_year)
|
84
|
+
|
85
|
+
solar_location = Solar::Location.new(lunar_age: lunar_age)
|
86
|
+
solar_location.run
|
87
|
+
|
88
|
+
solar_term_index = solar_location.index
|
89
|
+
|
90
|
+
# 入定気の一つ後の二十四節気まで戻す(ただし11月経朔が二十四節気上にある場合は戻さない)
|
91
|
+
# NOTE: 789年で大余0のパターンあり
|
92
|
+
solar_term_index += 1 unless solar_location.remainder.day.zero?
|
93
|
+
|
94
|
+
solar_term_index
|
95
|
+
end
|
94
96
|
end
|
95
97
|
end
|
96
98
|
end
|
@@ -83,24 +83,26 @@ module Zakuro
|
|
83
83
|
MAP[:taisetsu] # 23
|
84
84
|
].freeze
|
85
85
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
86
|
+
class << self
|
87
|
+
#
|
88
|
+
# 入気定日加減数を引き当てる
|
89
|
+
#
|
90
|
+
# @param [Integer] index 二十四節気番号
|
91
|
+
#
|
92
|
+
# @return [Cycle::Remainder] 入気定日加減数
|
93
|
+
#
|
94
|
+
def index_of(index)
|
95
|
+
LIST[index]
|
96
|
+
end
|
96
97
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
98
|
+
#
|
99
|
+
# 入気定日加減数の総数を返す
|
100
|
+
#
|
101
|
+
# @return [Integer] 入気定日加減数の総数
|
102
|
+
#
|
103
|
+
def size
|
104
|
+
LIST.size
|
105
|
+
end
|
104
106
|
end
|
105
107
|
end
|
106
108
|
end
|
@@ -16,19 +16,21 @@ module Zakuro
|
|
16
16
|
# Value 太陽補正値
|
17
17
|
#
|
18
18
|
module Value
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
class << self
|
20
|
+
#
|
21
|
+
# 太陽の運行による補正値を算出する
|
22
|
+
#
|
23
|
+
# @param [SolarTerm] solar_location 入定気
|
24
|
+
#
|
25
|
+
# @return [Integer] 補正値
|
26
|
+
#
|
27
|
+
def get(solar_location:)
|
28
|
+
remainder = solar_location.remainder
|
28
29
|
|
29
|
-
|
30
|
+
row = Adjustment.specify(index: solar_location.index)
|
30
31
|
|
31
|
-
|
32
|
+
Calculation::Solar::ChoukeiValue.get(remainder: remainder, row: row)
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
@@ -30,7 +30,7 @@ module Zakuro
|
|
30
30
|
# @param [Integer] total 繰り上げなしの小余
|
31
31
|
#
|
32
32
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
33
|
-
super(base_day: Const::Number::Cycle::DAY,
|
33
|
+
super(base_day: Const::Number::Cycle::DAY, base_minute: MINUTE,
|
34
34
|
day: day, minute: minute, second: second, total: total)
|
35
35
|
end
|
36
36
|
|
@@ -42,7 +42,7 @@ module Zakuro
|
|
42
42
|
def format(form: '%.4f', digit: 4)
|
43
43
|
return '' if invalid?
|
44
44
|
|
45
|
-
decimal =
|
45
|
+
decimal = day + minute / base_day.to_f
|
46
46
|
super(form, decimal.round(digit))
|
47
47
|
end
|
48
48
|
end
|
@@ -67,7 +67,7 @@ module Zakuro
|
|
67
67
|
# @param [Integer] total 繰り上げなしの小余
|
68
68
|
#
|
69
69
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
70
|
-
super(base_day: Const::Number::Cycle::TERM_DAY,
|
70
|
+
super(base_day: Const::Number::Cycle::TERM_DAY, base_minute: MINUTE,
|
71
71
|
day: day, minute: minute, second: second, total: total)
|
72
72
|
end
|
73
73
|
|
@@ -79,7 +79,7 @@ module Zakuro
|
|
79
79
|
def format(form: '%.4f', digit: 4)
|
80
80
|
return '' if invalid?
|
81
81
|
|
82
|
-
decimal =
|
82
|
+
decimal = day + minute / base_day.to_f
|
83
83
|
# NOTE: roundなしで format を使用した場合は、四捨五入が正しく実行されないことが判明した
|
84
84
|
# 具体的には、468年の中気は '55.7813' だが '55.7812' になる
|
85
85
|
# これは '55.7812500' を4桁にした際に、境界値の少数点以下5桁目の '5' が切り捨てを受けたためである
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../../../calculation/monthly/const'
|
4
|
+
|
3
5
|
require_relative '../const/remainder'
|
4
6
|
|
5
7
|
require_relative '../cycle/solar_term'
|
@@ -21,11 +23,11 @@ module Zakuro
|
|
21
23
|
# @return [Cycle::Remainder] 弦
|
22
24
|
QUARTER = Const::Remainder::QUARTER
|
23
25
|
|
24
|
-
# TODO: AbstractLunarPhase でも使用している
|
25
|
-
|
26
26
|
# @return [Array<String>] 月内の弦
|
27
|
-
PHASE_INDEXES =
|
27
|
+
PHASE_INDEXES = Calculation::Monthly::Const::PHASE_INDEXES
|
28
28
|
|
29
|
+
# @return [Integer] 弦の位置
|
30
|
+
attr_reader :index
|
29
31
|
# @return [Cycle::AbstractRemainder] 経
|
30
32
|
attr_reader :remainder
|
31
33
|
|
@@ -80,12 +82,12 @@ module Zakuro
|
|
80
82
|
#
|
81
83
|
def next_index
|
82
84
|
@index += 1
|
83
|
-
@index = 0 if
|
85
|
+
@index = 0 if index >= PHASE_INDEXES.size
|
84
86
|
@index
|
85
87
|
end
|
86
88
|
|
87
89
|
def add_quarter_moon_size
|
88
|
-
|
90
|
+
remainder.add!(QUARTER)
|
89
91
|
|
90
92
|
next_index
|
91
93
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../calculation/option/dropped_date/abstract_parameter'
|
4
|
+
|
5
|
+
require_relative '../../const/number'
|
6
|
+
require_relative '../../const/remainder'
|
7
|
+
require_relative '../../cycle/remainder'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
# :nodoc:
|
12
|
+
module Genka
|
13
|
+
# :nodoc:
|
14
|
+
module Option
|
15
|
+
# :nodoc:
|
16
|
+
module DroppedDate
|
17
|
+
#
|
18
|
+
# Parameter 引数
|
19
|
+
#
|
20
|
+
class Parameter < Calculation::Option::DroppedDate::AbstractParameter
|
21
|
+
#
|
22
|
+
# 初期化
|
23
|
+
#
|
24
|
+
def initialize
|
25
|
+
super(valid: false)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -18,58 +18,62 @@ module Zakuro
|
|
18
18
|
# @return [Output::Logger] ロガー
|
19
19
|
LOGGER = Output::Logger.new(location: 'annual_range')
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
21
|
+
class << self
|
22
|
+
#
|
23
|
+
# 一覧取得する
|
24
|
+
#
|
25
|
+
# * 対象年に対して、当年1月-翌年1月までを出力する
|
26
|
+
# * 対象年(西暦)と計算年(元号x年)の紐付けは行わない
|
27
|
+
#
|
28
|
+
# @param [Context::Context] context 暦コンテキスト
|
29
|
+
# @param [Integer] western_year 西暦年
|
30
|
+
#
|
31
|
+
# @return [Array<Month>] 1年データ
|
32
|
+
#
|
33
|
+
def get(context:, western_year:)
|
34
|
+
# 正月中気
|
35
|
+
solar_term = Cycle::SolarTerm.new(
|
36
|
+
index: 4, remainder: Origin::FirstTerm.get(western_year: western_year)
|
37
|
+
)
|
38
|
+
# 正月に立春が含まれる可能性があるので、立春まで戻しておく
|
39
|
+
solar_term.prev_term!
|
39
40
|
|
40
|
-
|
41
|
-
|
41
|
+
# 経
|
42
|
+
remainder = Origin::January.get(western_year: western_year)
|
42
43
|
|
43
|
-
|
44
|
+
lunar_phase = Monthly::LunarPhase.new(remainder: remainder)
|
44
45
|
|
45
|
-
|
46
|
+
solar_average = Solar::Average.new(solar_term: solar_term)
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
annual_range = Calculation::Range::MedievalAnnualRange.get(
|
49
|
+
context: context, lunar_phase: lunar_phase, solar_average: solar_average
|
50
|
+
)
|
50
51
|
|
51
|
-
|
52
|
-
|
52
|
+
pop_months_on_next_year(annual_range: annual_range)
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
# 来年の月を除去する
|
56
|
-
#
|
57
|
-
# @param [Array<Month>] annual_range 1年データ
|
58
|
-
#
|
59
|
-
# @return [Array<Month>] 1年データ
|
60
|
-
#
|
61
|
-
def self.pop_months_on_next_year(annual_range:)
|
62
|
-
result = []
|
63
|
-
number = 0
|
64
|
-
annual_range.each do |month|
|
65
|
-
# 来年
|
66
|
-
break if number > month.month_label.number
|
55
|
+
private
|
67
56
|
|
68
|
-
|
69
|
-
|
70
|
-
|
57
|
+
#
|
58
|
+
# 来年の月を除去する
|
59
|
+
#
|
60
|
+
# @param [Array<Month>] annual_range 1年データ
|
61
|
+
#
|
62
|
+
# @return [Array<Month>] 1年データ
|
63
|
+
#
|
64
|
+
def pop_months_on_next_year(annual_range:)
|
65
|
+
result = []
|
66
|
+
number = 0
|
67
|
+
annual_range.each do |month|
|
68
|
+
# 来年
|
69
|
+
break if number > month.month_label.number
|
71
70
|
|
72
|
-
|
71
|
+
number = month.month_label.number
|
72
|
+
result.push(month)
|
73
|
+
end
|
74
|
+
|
75
|
+
result
|
76
|
+
end
|
73
77
|
end
|
74
78
|
end
|
75
79
|
end
|
@@ -20,34 +20,36 @@ module Zakuro
|
|
20
20
|
# @return [Integer] 西暦0年の積年
|
21
21
|
WESTERN_YEAR = Const::Number::Stack::WESTERN_YEAR
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
23
|
+
class << self
|
24
|
+
#
|
25
|
+
# 年初の中気(正月中雨水)を求める
|
26
|
+
#
|
27
|
+
# @note 計算は宋書(1)に従う。念のため『日本暦日原典』(2)と比較する
|
28
|
+
# 1. (1612 + 西暦年) * 餘数(1595) / 度法(304) = A' ...余りが中気の小余
|
29
|
+
# A' / 60 = B' ...余りが朔の大余
|
30
|
+
# 『歴代天文律暦等志彙編 六』中華書房 p.1728
|
31
|
+
#
|
32
|
+
# 2. (1612 + x) * 222070 / 608 = A' ...余りが中気の小余
|
33
|
+
# A' / 60 = B' ...余りが朔の大余
|
34
|
+
#
|
35
|
+
# 小余上限(度法)の違いで、宋書に従ったほうが良いと判断した。分母が変わるだけで結果に相違はない
|
36
|
+
#
|
37
|
+
# @param [Integer] western_year 西暦年
|
38
|
+
#
|
39
|
+
# @return [Remainder] 年初の中気(正月中雨水)
|
40
|
+
#
|
41
|
+
def get(western_year:)
|
42
|
+
total_western_year = WESTERN_YEAR + western_year
|
43
|
+
# (1612 + x) * 222070 / 608 = A' ...余りが中気の小余
|
44
|
+
stack = (total_western_year * YEAR_REMAINDER / TERM_DAY).to_i
|
45
|
+
minute = (total_western_year * YEAR_REMAINDER % TERM_DAY).to_i
|
46
|
+
# A' / 60 = B' ...余りが朔の大余
|
47
|
+
day = stack % Cycle::TermRemainder::LIMIT
|
48
|
+
# p stack
|
49
|
+
# p minute
|
50
|
+
# p day
|
51
|
+
Cycle::TermRemainder.new(day: day, minute: minute, second: 0)
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|