zakuro 0.1.5 → 0.5.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 +17 -1
- data/doc/gengou.md +22 -22
- data/doc/operation/csv/month.csv +468 -202
- data/doc/operation/operation.xlsx +0 -0
- data/lib/zakuro/calculation/base/operated_year.rb +114 -0
- data/lib/zakuro/calculation/base/year.rb +3 -0
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +29 -29
- data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +169 -0
- data/lib/zakuro/calculation/monthly/first_day.rb +1 -1
- data/lib/zakuro/calculation/monthly/operated_month.rb +47 -3
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +105 -0
- data/lib/zakuro/calculation/range/operated_range.rb +61 -16
- data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +78 -0
- data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +71 -0
- data/lib/zakuro/calculation/stella/solar/abstract_average.rb +117 -0
- data/lib/zakuro/calculation/stella/solar/abstract_location.rb +187 -0
- data/lib/zakuro/calculation/stella/solar/choukei_value.rb +136 -0
- data/lib/zakuro/calculation/type/old_float.rb +69 -0
- data/lib/zakuro/era/japan/reki.rb +1 -1
- data/lib/zakuro/era/japan/yaml/set-001-until-south.yaml +22 -22
- data/lib/zakuro/operation/month/type.rb +58 -0
- data/lib/zakuro/operation/yaml/month.yaml +8512 -0
- data/lib/zakuro/version/context.rb +1 -1
- data/lib/zakuro/version/daien/const/number.rb +55 -0
- data/lib/zakuro/version/daien/const/remainder.rb +53 -0
- data/lib/zakuro/version/daien/cycle/remainder.rb +85 -0
- data/lib/zakuro/version/daien/cycle/solar_term.rb +34 -0
- data/lib/zakuro/version/daien/daien.rb +36 -0
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +106 -0
- data/lib/zakuro/version/daien/range/annual_range.rb +39 -0
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +240 -0
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +44 -0
- data/lib/zakuro/version/daien/stella/lunar/location.rb +80 -0
- data/lib/zakuro/version/daien/stella/lunar/value.rb +75 -0
- data/lib/zakuro/version/daien/stella/origin/average_november.rb +34 -0
- data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +62 -0
- data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +55 -0
- data/lib/zakuro/version/daien/stella/solar/adjustment.rb +93 -0
- data/lib/zakuro/version/daien/stella/solar/average.rb +98 -0
- data/lib/zakuro/version/daien/stella/solar/interval.rb +108 -0
- data/lib/zakuro/version/daien/stella/solar/location.rb +61 -0
- data/lib/zakuro/version/daien/stella/solar/value.rb +36 -0
- data/lib/zakuro/version/genka/const/number.rb +43 -0
- data/lib/zakuro/version/genka/const/remainder.rb +33 -0
- data/lib/zakuro/version/genka/cycle/remainder.rb +92 -0
- data/lib/zakuro/version/genka/cycle/solar_term.rb +34 -0
- data/lib/zakuro/version/genka/genka.rb +19 -2
- data/lib/zakuro/version/genka/monthly/lunar_phase.rb +95 -0
- data/lib/zakuro/version/genka/range/annual_range.rb +77 -0
- data/lib/zakuro/version/genka/stella/origin/first_term.rb +55 -0
- data/lib/zakuro/version/genka/stella/origin/january.rb +49 -0
- data/lib/zakuro/version/genka/stella/solar/average.rb +41 -0
- data/lib/zakuro/version/gihou/const/number.rb +55 -0
- data/lib/zakuro/version/gihou/const/remainder.rb +54 -0
- data/lib/zakuro/version/gihou/cycle/remainder.rb +82 -0
- data/lib/zakuro/version/gihou/cycle/solar_term.rb +34 -0
- data/lib/zakuro/version/gihou/gihou.rb +23 -2
- data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +106 -0
- data/lib/zakuro/version/gihou/range/annual_range.rb +39 -0
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +250 -0
- data/lib/zakuro/version/gihou/stella/lunar/localization.rb +44 -0
- data/lib/zakuro/version/gihou/stella/lunar/location.rb +80 -0
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +75 -0
- data/lib/zakuro/version/gihou/stella/origin/average_november.rb +34 -0
- data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +62 -0
- data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +55 -0
- data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +93 -0
- data/lib/zakuro/version/gihou/stella/solar/average.rb +97 -0
- data/lib/zakuro/version/gihou/stella/solar/interval.rb +108 -0
- data/lib/zakuro/version/gihou/stella/solar/location.rb +61 -0
- data/lib/zakuro/version/gihou/stella/solar/value.rb +36 -0
- data/lib/zakuro/version/senmyou/const/number.rb +1 -1
- data/lib/zakuro/version/senmyou/const/remainder.rb +7 -3
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +27 -6
- data/lib/zakuro/version/senmyou/cycle/solar_term.rb +4 -1
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +12 -112
- data/lib/zakuro/version/senmyou/range/annual_range.rb +5 -77
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +2 -3
- data/lib/zakuro/version/senmyou/stella/lunar/location.rb +13 -34
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +8 -30
- data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +29 -29
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +14 -92
- data/lib/zakuro/version/senmyou/stella/solar/location.rb +18 -121
- data/lib/zakuro/version/senmyou/stella/solar/value.rb +4 -103
- data/lib/zakuro/version/version_class_resolver.rb +12 -0
- data/lib/zakuro/version.rb +1 -1
- data/lib/zakuro/version_factory.rb +1 -1
- metadata +61 -7
- data/lib/zakuro/version/taien/taien.rb +0 -19
@@ -11,7 +11,7 @@ module Zakuro
|
|
11
11
|
attr_reader :version_name
|
12
12
|
attr_reader :resolver
|
13
13
|
|
14
|
-
VERSION_NAMES = %w[Genka Gihou
|
14
|
+
VERSION_NAMES = %w[Genka Gihou Daien Senmyou Joukyou Kansei Tenpou Gregorio].freeze
|
15
15
|
|
16
16
|
def initialize(version_name:)
|
17
17
|
raise ArgumentError.new, 'invalid version' unless VERSION_NAMES.include?(version_name)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :nodoc:
|
4
|
+
module Zakuro
|
5
|
+
# :nodoc:
|
6
|
+
module Daien
|
7
|
+
#
|
8
|
+
# Const 定数
|
9
|
+
#
|
10
|
+
module Const
|
11
|
+
#
|
12
|
+
# Number 数値
|
13
|
+
#
|
14
|
+
module Number
|
15
|
+
#
|
16
|
+
# Cycle 周期
|
17
|
+
#
|
18
|
+
module Cycle
|
19
|
+
# @return [Integer] 通法(1日=3040分)
|
20
|
+
DAY = 3040
|
21
|
+
#
|
22
|
+
# @return [Float] 転日(1近点月 = 27日1685分79秒(1分=80秒))
|
23
|
+
# @note 小数点以下の値によって大幅に結果が変わる。除算結果を設定した
|
24
|
+
#
|
25
|
+
ANOMALISTIC_MONTH = 83_765 + (79.0 / 80)
|
26
|
+
# @return [Integer] 朔望月
|
27
|
+
SYNODIC_MONTH = 89_773
|
28
|
+
# @return [Integer] 一年
|
29
|
+
YEAR = 1_110_343
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Derivation 導出
|
34
|
+
#
|
35
|
+
module Derivation
|
36
|
+
# @return [Integer] 通余: (YEAR - DAY * 12 * 30)
|
37
|
+
# 1110343 - 1094400
|
38
|
+
REMAINDER_ALL_YEAR = 15_943
|
39
|
+
# @return [Integer] 旬周(60日) DAY * 60
|
40
|
+
SIXTY_DAYS = 182_400
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# 累積
|
45
|
+
#
|
46
|
+
module Stack
|
47
|
+
# @return [Integer] 積年(甲子夜半朔旦冬至〜暦の開始前)
|
48
|
+
TOTAL_YEAR = 96_961_740
|
49
|
+
# @return [Integer] 暦の開始年(開元12年)
|
50
|
+
BEGIN_YEAR = 724
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../cycle/remainder'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
# :nodoc:
|
8
|
+
module Daien
|
9
|
+
#
|
10
|
+
# Const 定数
|
11
|
+
#
|
12
|
+
module Const
|
13
|
+
#
|
14
|
+
# Remainder 大余小余
|
15
|
+
#
|
16
|
+
module Remainder
|
17
|
+
#
|
18
|
+
# Solar 太陽
|
19
|
+
#
|
20
|
+
module Solar
|
21
|
+
# @return [Remainder] 気策(24分の1年)
|
22
|
+
# 1年(1_110_343) / 24 / 1日(3040)= 15 余り 664.2916666666642
|
23
|
+
# * 0.2916666666642 * 24(1分=24秒) = 6.999999999940799 ≒ 7
|
24
|
+
SOLAR_TERM_AVERAGE = Cycle::Remainder.new(day: 15, minute: 664, second: 7)
|
25
|
+
#
|
26
|
+
# @note 揲法 89773 = 29-1613
|
27
|
+
# * 89773 / 4 = 22443.25 / 3040 = 7 余り 1163.25
|
28
|
+
# * 0.25 * 24(1分=24秒) = 6
|
29
|
+
#
|
30
|
+
# @return [Cycle::Remainder] 弦(1分=80秒)
|
31
|
+
QUARTER = Cycle::Remainder.new(day: 7, minute: 1163, second: 6)
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Lunar 月
|
36
|
+
#
|
37
|
+
module Lunar
|
38
|
+
# @return [Cycle::LunarRemainder] 転日(1近点月)
|
39
|
+
ANOMALISTIC_MONTH = \
|
40
|
+
Cycle::LunarRemainder.new(day: 27, minute: 1685, second: 79)
|
41
|
+
#
|
42
|
+
# @note 揲法 89773 = 29-1613
|
43
|
+
# * 89773 / 4 = 22443.25 / 3040 = 7 余り 1163.25
|
44
|
+
# * 0.25 * 80(1分=80秒) = 20
|
45
|
+
#
|
46
|
+
# @return [Cycle::LunarRemainder] 弦(1分=80秒)
|
47
|
+
# TODO: 秒が20では通らない。少なくとも0.01247は必要になる
|
48
|
+
QUARTER = Cycle::LunarRemainder.new(day: 7, minute: 1163, second: 20.01247)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../calculation/cycle/abstract_remainder'
|
4
|
+
|
5
|
+
require_relative '../const/number'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
# :nodoc:
|
10
|
+
module Daien
|
11
|
+
# :nodoc:
|
12
|
+
module Cycle
|
13
|
+
#
|
14
|
+
# Remainder 時刻情報(大余小余)
|
15
|
+
#
|
16
|
+
class Remainder < Calculation::Cycle::AbstractRemainder
|
17
|
+
# 『歴代天文律暦等志彙編 七』中華書房 p.2056
|
18
|
+
# 「象統;二十四」「其秒盈象統,従小餘」
|
19
|
+
# 上記は舊唐志の記述だが、新唐志(p.2218)でも同様であることを確認した
|
20
|
+
# @return [Integer] 分(1分=24秒)
|
21
|
+
MINUTE = 24
|
22
|
+
|
23
|
+
#
|
24
|
+
# 初期化
|
25
|
+
#
|
26
|
+
# @param [Integer] day 大余("日"に相当)
|
27
|
+
# @param [Integer] minute 小余("分"に相当)
|
28
|
+
# @param [Integer] second 秒
|
29
|
+
# @param [Integer] total 繰り上げなしの小余
|
30
|
+
#
|
31
|
+
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
32
|
+
super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
|
33
|
+
day: day, minute: minute, second: second, total: total)
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# 特定の文字フォーマットにして出力する
|
38
|
+
#
|
39
|
+
# @param [String] form フォーマット(大余、小余、秒それぞれを%dで指定する)
|
40
|
+
#
|
41
|
+
# @return [String] フォーマットした結果
|
42
|
+
#
|
43
|
+
def format(form: '%d-%d')
|
44
|
+
return '' if invalid?
|
45
|
+
|
46
|
+
super(form, @day, @minute, @second)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# LunarRemainder 月の位相計算向け時刻情報(大余小余)
|
52
|
+
#
|
53
|
+
class LunarRemainder < Calculation::Cycle::AbstractRemainder
|
54
|
+
# @return [Integer] 分(1分=80秒)
|
55
|
+
MINUTE = 80
|
56
|
+
|
57
|
+
#
|
58
|
+
# 初期化
|
59
|
+
#
|
60
|
+
# @param [Integer] day 大余("日"に相当)
|
61
|
+
# @param [Integer] minute 小余("分"に相当)
|
62
|
+
# @param [Integer] second 秒
|
63
|
+
# @param [Integer] total 繰り上げなしの小余
|
64
|
+
#
|
65
|
+
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
66
|
+
super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
|
67
|
+
day: day, minute: minute, second: second, total: total)
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# 特定の文字フォーマットにして出力する
|
72
|
+
#
|
73
|
+
# @param [String] form フォーマット(大余、小余、秒それぞれを%dで指定する)
|
74
|
+
#
|
75
|
+
# @return [String] フォーマットした結果
|
76
|
+
#
|
77
|
+
def format(form: '%d-%d')
|
78
|
+
return '' if invalid?
|
79
|
+
|
80
|
+
super(form, @day, @minute, @second)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../calculation/cycle/abstract_solar_term'
|
4
|
+
|
5
|
+
require_relative '../const/remainder'
|
6
|
+
|
7
|
+
require_relative './remainder'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
# :nodoc:
|
12
|
+
module Daien
|
13
|
+
# :nodoc:
|
14
|
+
module Cycle
|
15
|
+
#
|
16
|
+
# SolarTerm 二十四節気
|
17
|
+
#
|
18
|
+
class SolarTerm < Calculation::Cycle::AbstractSolarTerm
|
19
|
+
# @return [Remainder] 気策(24分の1年)
|
20
|
+
SOLAR_TERM_AVERAGE = Const::Remainder::Solar::SOLAR_TERM_AVERAGE
|
21
|
+
|
22
|
+
#
|
23
|
+
# 初期化
|
24
|
+
#
|
25
|
+
# @param [Integer] index 連番
|
26
|
+
# @param [Remainder] remainder 時刻情報(大余小余)
|
27
|
+
#
|
28
|
+
def initialize(index: -1, remainder: Remainder.new)
|
29
|
+
super(index: index, remainder: remainder, average: SOLAR_TERM_AVERAGE)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../abstract_version'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
#
|
8
|
+
# Daien 大衍暦
|
9
|
+
#
|
10
|
+
module Daien
|
11
|
+
#
|
12
|
+
# Gateway アクセサメソッド群
|
13
|
+
#
|
14
|
+
class Gateway < AbstractVersion
|
15
|
+
# @return [True] リリースあり
|
16
|
+
RELEASE = true
|
17
|
+
|
18
|
+
# @return [String] 暦クラス名
|
19
|
+
VERSION_NAME = 'Daien'
|
20
|
+
|
21
|
+
#
|
22
|
+
# 西暦日から和暦日に変換する
|
23
|
+
#
|
24
|
+
# @param [Date] western_date 西暦日
|
25
|
+
#
|
26
|
+
# @return [Result::Single] 和暦日
|
27
|
+
#
|
28
|
+
def self.to_japan_date(western_date:)
|
29
|
+
date = Western::Calendar.create(date: western_date)
|
30
|
+
|
31
|
+
context = Context.new(version_name: VERSION_NAME)
|
32
|
+
Calculation::Summary::Single.get(context: context, date: date)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../calculation/monthly/abstract_lunar_phase'
|
4
|
+
|
5
|
+
require_relative '../const/remainder'
|
6
|
+
|
7
|
+
require_relative '../stella/solar/location'
|
8
|
+
require_relative '../stella/solar/value'
|
9
|
+
require_relative '../stella/lunar/location'
|
10
|
+
require_relative '../stella/lunar/value'
|
11
|
+
|
12
|
+
require_relative '../stella/origin/lunar_age'
|
13
|
+
require_relative '../stella/origin/average_november'
|
14
|
+
|
15
|
+
# :nodoc:
|
16
|
+
module Zakuro
|
17
|
+
# :nodoc:
|
18
|
+
module Daien
|
19
|
+
# :nodoc:
|
20
|
+
module Monthly
|
21
|
+
#
|
22
|
+
# LunarPhase 月の位相
|
23
|
+
#
|
24
|
+
class LunarPhase < Calculation::Monthly::AbstractLunarPhase
|
25
|
+
# @return [Cycle::Remainder] 弦
|
26
|
+
QUARTER = Const::Remainder::Solar::QUARTER
|
27
|
+
|
28
|
+
#
|
29
|
+
# 初期化
|
30
|
+
#
|
31
|
+
# @param [Integer] western_year 西暦年
|
32
|
+
#
|
33
|
+
def initialize(western_year:)
|
34
|
+
# 天正閏余
|
35
|
+
lunar_age = Origin::LunarAge.get(western_year: western_year)
|
36
|
+
|
37
|
+
super(
|
38
|
+
quater: QUARTER,
|
39
|
+
average_remainder: Origin::AverageNovember.get(western_year: western_year),
|
40
|
+
solar_location: Solar::Location.new(lunar_age: lunar_age),
|
41
|
+
lunar_location: Lunar::Location.new(
|
42
|
+
western_year: western_year,
|
43
|
+
lunar_age: Cycle::LunarRemainder.new(total: 0).add!(lunar_age)
|
44
|
+
)
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
# :reek:TooManyStatements { max_statements: 6 }
|
51
|
+
|
52
|
+
#
|
53
|
+
# 現在の定朔を取得する
|
54
|
+
#
|
55
|
+
# @return [Remainder] 定朔
|
56
|
+
#
|
57
|
+
def current_remainder
|
58
|
+
# debug("@average_remainder.format: #{@average_remainder.format(form: '%d-%d-%.5f')}")
|
59
|
+
|
60
|
+
sum = correction_value
|
61
|
+
adjusted = @average_remainder.add(
|
62
|
+
Cycle::Remainder.new(day: 0, minute: sum, second: 0)
|
63
|
+
)
|
64
|
+
# TODO: 大衍暦では進朔するか
|
65
|
+
# adjusted.up_on_new_moon!
|
66
|
+
|
67
|
+
debug("result: #{adjusted.format}")
|
68
|
+
|
69
|
+
adjusted
|
70
|
+
end
|
71
|
+
|
72
|
+
#
|
73
|
+
# 太陽運動の補正値を得る
|
74
|
+
#
|
75
|
+
# @return [Integer] 太陽運動の補正値
|
76
|
+
#
|
77
|
+
def correction_solar_value
|
78
|
+
@solar_location.run
|
79
|
+
# debug("@solar_term.remainder: #{@solar_location.remainder.format(form: '%d-%d-%.5f')}")
|
80
|
+
# debug("@solar_term.index: #{@solar_location.index}")
|
81
|
+
|
82
|
+
Solar::Value.get(solar_location: @solar_location)
|
83
|
+
end
|
84
|
+
|
85
|
+
# :reek:TooManyStatements { max_statements: 6 }
|
86
|
+
|
87
|
+
#
|
88
|
+
# 月運動の補正値を得る
|
89
|
+
#
|
90
|
+
# @return [Integer] 月運動の補正値
|
91
|
+
#
|
92
|
+
def correction_moon_value
|
93
|
+
@lunar_location.run
|
94
|
+
|
95
|
+
remainder = @lunar_location.adjusted_remainder
|
96
|
+
|
97
|
+
# debug("[lunar]remainder.format: #{remainder.format(form: '%d-%d-%.5f')}")
|
98
|
+
# debug("[lunar]remainder.day: #{remainder.day}")
|
99
|
+
# debug("[lunar]remainder.minute: #{remainder.minute}")
|
100
|
+
|
101
|
+
Lunar::Value.get(remainder: remainder)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../calculation/range/medieval_annual_range'
|
4
|
+
require_relative '../monthly/lunar_phase'
|
5
|
+
require_relative '../stella/solar/average'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
# :nodoc:
|
10
|
+
module Daien
|
11
|
+
# :nodoc:
|
12
|
+
module Range
|
13
|
+
#
|
14
|
+
# AnnualRange 年間範囲
|
15
|
+
#
|
16
|
+
module AnnualRange
|
17
|
+
#
|
18
|
+
# 一覧取得する
|
19
|
+
#
|
20
|
+
# * 対象年に対して、前年11月-当年11月までを出力する
|
21
|
+
# * 対象年(西暦)と計算年(元号x年)の紐付けは行わない
|
22
|
+
#
|
23
|
+
# @param [Context] context 暦コンテキスト
|
24
|
+
# @param [Integer] western_year 西暦年
|
25
|
+
#
|
26
|
+
# @return [Array<Month>] 1年データ
|
27
|
+
#
|
28
|
+
def self.get(context:, western_year:)
|
29
|
+
lunar_phase = Monthly::LunarPhase.new(western_year: western_year)
|
30
|
+
solar_average = Solar::Average.new(western_year: western_year)
|
31
|
+
|
32
|
+
Calculation::Range::MedievalAnnualRange.get(
|
33
|
+
context: context, lunar_phase: lunar_phase, solar_average: solar_average
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,240 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../const/number'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
# :nodoc:
|
8
|
+
module Daien
|
9
|
+
# :nodoc:
|
10
|
+
module Lunar
|
11
|
+
#
|
12
|
+
# Adjustment 補正値情報
|
13
|
+
#
|
14
|
+
module Adjustment
|
15
|
+
# 『歴代天文律暦等志彙編 七』中華書房 p.2230
|
16
|
+
#
|
17
|
+
# 遠/近の地点での中間
|
18
|
+
#
|
19
|
+
# @return [Hash<Integer>] 遠/近の地点での中間
|
20
|
+
DAY_LIMIT = {
|
21
|
+
7 => 2701,
|
22
|
+
14 => 2363,
|
23
|
+
21 => 2024,
|
24
|
+
28 => 1686
|
25
|
+
}.freeze
|
26
|
+
|
27
|
+
#
|
28
|
+
# Row 行情報
|
29
|
+
#
|
30
|
+
class Row
|
31
|
+
# @return [Integer] 入暦(1-14)
|
32
|
+
attr_reader :day
|
33
|
+
# @return [Range] 小余範囲
|
34
|
+
attr_reader :range
|
35
|
+
# @return [Value] 補正値
|
36
|
+
attr_reader :value
|
37
|
+
|
38
|
+
#
|
39
|
+
# 初期化
|
40
|
+
#
|
41
|
+
# @param [Integer] day 入暦(1-14)
|
42
|
+
# @param [Range] range 小余範囲
|
43
|
+
# @param [Value] value 補正値
|
44
|
+
#
|
45
|
+
def initialize(day:, range:, value:)
|
46
|
+
@day = day
|
47
|
+
@range = range
|
48
|
+
@value = value
|
49
|
+
end
|
50
|
+
|
51
|
+
# :reek:ControlParameter
|
52
|
+
|
53
|
+
#
|
54
|
+
# 一致するか
|
55
|
+
#
|
56
|
+
# @param [Integer] day 入暦(1-14)
|
57
|
+
# @param [Integer] minute 小余
|
58
|
+
#
|
59
|
+
# @return [True] 一致
|
60
|
+
# @return [False] 不一致
|
61
|
+
#
|
62
|
+
def match?(day:, minute:)
|
63
|
+
return false unless @day == day
|
64
|
+
|
65
|
+
return false unless @range.include?(minute: minute)
|
66
|
+
|
67
|
+
true
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# 分母を返す
|
72
|
+
#
|
73
|
+
# @return [Integer] 分母
|
74
|
+
#
|
75
|
+
def denominator
|
76
|
+
@range.denominator
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Range 小余範囲
|
82
|
+
#
|
83
|
+
class Range
|
84
|
+
# @return [Integer] 下限
|
85
|
+
MIN = 0
|
86
|
+
# @return [Integer] 上限
|
87
|
+
MAX = Const::Number::Cycle::DAY
|
88
|
+
|
89
|
+
# @return [Integer] 下限
|
90
|
+
attr_reader :min
|
91
|
+
# @return [Integer] 上限
|
92
|
+
attr_reader :max
|
93
|
+
|
94
|
+
#
|
95
|
+
# 初期化
|
96
|
+
#
|
97
|
+
# @param [Integer] min 下限
|
98
|
+
# @param [Integer] max 上限
|
99
|
+
#
|
100
|
+
def initialize(min: MIN, max: MAX)
|
101
|
+
@min = min
|
102
|
+
@max = max
|
103
|
+
end
|
104
|
+
|
105
|
+
#
|
106
|
+
# 含まれるか
|
107
|
+
#
|
108
|
+
# @param [Integer] minute 小余
|
109
|
+
#
|
110
|
+
# @return [True] 含まれる
|
111
|
+
# @return [False] 含まれない
|
112
|
+
#
|
113
|
+
def include?(minute:)
|
114
|
+
minute >= @min && minute <= @max
|
115
|
+
end
|
116
|
+
|
117
|
+
#
|
118
|
+
# 分母を返す
|
119
|
+
#
|
120
|
+
# @return [Integer] 分母
|
121
|
+
#
|
122
|
+
def denominator
|
123
|
+
@max - @min
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
#
|
128
|
+
# Value 補正値
|
129
|
+
#
|
130
|
+
class Value
|
131
|
+
# @return [Integer] 増減率
|
132
|
+
attr_reader :per
|
133
|
+
# @return [Integer] 遅速積
|
134
|
+
attr_reader :stack
|
135
|
+
|
136
|
+
#
|
137
|
+
# 初期化
|
138
|
+
#
|
139
|
+
# @param [Integer] per 増減率
|
140
|
+
# @param [Integer] stack 遅速積
|
141
|
+
#
|
142
|
+
def initialize(per:, stack:)
|
143
|
+
@per = per
|
144
|
+
@stack = stack
|
145
|
+
end
|
146
|
+
|
147
|
+
#
|
148
|
+
# 文字化
|
149
|
+
#
|
150
|
+
# @return [String] 文字
|
151
|
+
#
|
152
|
+
def to_s
|
153
|
+
"per:#{@per}, stack:#{@stack}"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# rubocop:disable Layout/LineLength
|
158
|
+
|
159
|
+
# 『歴代天文律暦等志彙編 七』中華書房 p.2228-2230
|
160
|
+
#
|
161
|
+
# @note 7日、14日、21日、28日の小余は DAY_LIMIT を参照のこと
|
162
|
+
#
|
163
|
+
# @return [Array<Row>] 月の補正値情報
|
164
|
+
#
|
165
|
+
LIST = [
|
166
|
+
Row.new(day: 1, range: Range.new, value: Value.new(per: +297, stack: 0)),
|
167
|
+
Row.new(day: 2, range: Range.new, value: Value.new(per: +259, stack: +297)),
|
168
|
+
Row.new(day: 3, range: Range.new, value: Value.new(per: +220, stack: +556)),
|
169
|
+
Row.new(day: 4, range: Range.new, value: Value.new(per: +180, stack: +776)),
|
170
|
+
Row.new(day: 5, range: Range.new, value: Value.new(per: +139, stack: +956)),
|
171
|
+
Row.new(day: 6, range: Range.new, value: Value.new(per: +97, stack: +1095)),
|
172
|
+
Row.new(day: 7, range: Range.new(max: DAY_LIMIT[7]), value: Value.new(per: +48, stack: +1192)),
|
173
|
+
Row.new(day: 7, range: Range.new(min: DAY_LIMIT[7]), value: Value.new(per: -6, stack: +1240)), # stack: +1192 + 48
|
174
|
+
Row.new(day: 8, range: Range.new, value: Value.new(per: -64, stack: +1234)),
|
175
|
+
Row.new(day: 9, range: Range.new, value: Value.new(per: -106, stack: +1170)),
|
176
|
+
Row.new(day: 10, range: Range.new, value: Value.new(per: -148, stack: +1064)),
|
177
|
+
Row.new(day: 11, range: Range.new, value: Value.new(per: -189, stack: +916)),
|
178
|
+
Row.new(day: 12, range: Range.new, value: Value.new(per: -229, stack: +727)),
|
179
|
+
Row.new(day: 13, range: Range.new, value: Value.new(per: -267, stack: +498)),
|
180
|
+
Row.new(day: 14, range: Range.new(max: DAY_LIMIT[14]), value: Value.new(per: -231, stack: +231)),
|
181
|
+
Row.new(day: 14, range: Range.new(min: DAY_LIMIT[14]), value: Value.new(per: -66, stack: 0)), # stack: +232 - 231
|
182
|
+
Row.new(day: 15, range: Range.new, value: Value.new(per: -289, stack: -66)),
|
183
|
+
Row.new(day: 16, range: Range.new, value: Value.new(per: -250, stack: -355)),
|
184
|
+
Row.new(day: 17, range: Range.new, value: Value.new(per: -211, stack: -605)),
|
185
|
+
Row.new(day: 18, range: Range.new, value: Value.new(per: -171, stack: -816)),
|
186
|
+
Row.new(day: 19, range: Range.new, value: Value.new(per: -130, stack: -987)),
|
187
|
+
Row.new(day: 20, range: Range.new, value: Value.new(per: -87, stack: -1117)),
|
188
|
+
Row.new(day: 21, range: Range.new(max: DAY_LIMIT[21]), value: Value.new(per: -36, stack: -1204)),
|
189
|
+
Row.new(day: 21, range: Range.new(min: DAY_LIMIT[21]), value: Value.new(per: +18, stack: -1240)), # stack: -1204 - 36
|
190
|
+
Row.new(day: 22, range: Range.new, value: Value.new(per: +73, stack: -1222)),
|
191
|
+
Row.new(day: 23, range: Range.new, value: Value.new(per: +116, stack: -1149)),
|
192
|
+
Row.new(day: 24, range: Range.new, value: Value.new(per: +157, stack: -1033)),
|
193
|
+
Row.new(day: 25, range: Range.new, value: Value.new(per: +198, stack: -876)),
|
194
|
+
Row.new(day: 26, range: Range.new, value: Value.new(per: +237, stack: -678)),
|
195
|
+
Row.new(day: 27, range: Range.new, value: Value.new(per: +276, stack: -441)),
|
196
|
+
Row.new(day: 28, range: Range.new(max: DAY_LIMIT[28]), value: Value.new(per: +165, stack: -165))
|
197
|
+
].freeze
|
198
|
+
# rubocop:enable Layout/LineLength
|
199
|
+
|
200
|
+
#
|
201
|
+
# 月軌道の補正に必要な基本値を引き当てる
|
202
|
+
#
|
203
|
+
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
204
|
+
# @param [Integer] day 大余
|
205
|
+
# @param [Integer] minute 小余
|
206
|
+
#
|
207
|
+
# @return [Row] 補正値
|
208
|
+
#
|
209
|
+
def self.specify(day:, minute:)
|
210
|
+
LIST.each do |row|
|
211
|
+
# NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
|
212
|
+
return row if row.match?(day: day, minute: minute)
|
213
|
+
end
|
214
|
+
|
215
|
+
raise ArgumentError.new, "invalid parameter: #{day}/#{minute}"
|
216
|
+
end
|
217
|
+
|
218
|
+
# :reek:ControlParameter
|
219
|
+
|
220
|
+
#
|
221
|
+
# 小余の下げ幅を求める
|
222
|
+
#
|
223
|
+
# @param [Integer] day 大余
|
224
|
+
# @param [Integer] minute 小余
|
225
|
+
#
|
226
|
+
# @return [Integer] 小余の下げ幅
|
227
|
+
#
|
228
|
+
def self.minus_minute(day:, minute:)
|
229
|
+
limit = DAY_LIMIT.fetch(day, -1)
|
230
|
+
# 該当なし
|
231
|
+
return minute if limit == -1
|
232
|
+
|
233
|
+
return minute unless minute > limit
|
234
|
+
|
235
|
+
minute - limit
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|