zakuro 0.2.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -1
  3. data/VERSION +1 -0
  4. data/doc/gengou.md +22 -22
  5. data/doc/operation/csv/month.csv +468 -202
  6. data/doc/operation/operation.xlsx +0 -0
  7. data/lib/zakuro/calculation/base/gengou.rb +82 -0
  8. data/lib/zakuro/calculation/base/linear_gengou.rb +76 -0
  9. data/lib/zakuro/calculation/base/operated_year.rb +104 -0
  10. data/lib/zakuro/calculation/base/year.rb +28 -13
  11. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +29 -29
  12. data/lib/zakuro/calculation/gengou/internal/counter.rb +129 -0
  13. data/lib/zakuro/calculation/gengou/internal/reserve/interval.rb +183 -0
  14. data/lib/zakuro/calculation/gengou/internal/reserve/list.rb +382 -0
  15. data/lib/zakuro/calculation/gengou/internal/reserve.rb +42 -0
  16. data/lib/zakuro/calculation/gengou/scroll.rb +262 -0
  17. data/lib/zakuro/calculation/monthly/first_day.rb +3 -2
  18. data/lib/zakuro/calculation/monthly/month.rb +49 -2
  19. data/lib/zakuro/calculation/monthly/operated_month.rb +49 -5
  20. data/lib/zakuro/calculation/range/full_range.rb +65 -103
  21. data/lib/zakuro/calculation/range/operated_range.rb +73 -23
  22. data/lib/zakuro/calculation/range/operated_solar_terms.rb +36 -17
  23. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +54 -0
  24. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +25 -21
  25. data/lib/zakuro/calculation/specifier/single_day.rb +13 -35
  26. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +9 -7
  27. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +19 -0
  28. data/lib/zakuro/calculation/summary/single.rb +5 -2
  29. data/lib/zakuro/calculation/version/internal/crawler.rb +51 -0
  30. data/lib/zakuro/calculation/version/internal/range.rb +39 -0
  31. data/lib/zakuro/calculation/version/version.rb +24 -0
  32. data/lib/zakuro/era/japan/calendar.rb +133 -0
  33. data/lib/zakuro/era/japan/gengou/parser.rb +95 -25
  34. data/lib/zakuro/era/japan/gengou/type.rb +148 -41
  35. data/lib/zakuro/era/japan/gengou/validator.rb +157 -52
  36. data/lib/zakuro/era/japan/gengou/yaml/set-001-until-south.yaml +1870 -0
  37. data/lib/zakuro/era/japan/gengou/yaml/set-002-from-north.yaml +810 -0
  38. data/lib/zakuro/era/japan/gengou/yaml/set-003-modern.yaml +50 -0
  39. data/lib/zakuro/era/japan/gengou.rb +5 -5
  40. data/lib/zakuro/era/japan/version.rb +151 -0
  41. data/lib/zakuro/era/{western.rb → western/calendar.rb} +0 -0
  42. data/lib/zakuro/merchant.rb +12 -3
  43. data/lib/zakuro/operation/month/parser.rb +1 -1
  44. data/lib/zakuro/operation/month/type.rb +59 -1
  45. data/lib/zakuro/operation/month/validator.rb +1 -1
  46. data/lib/zakuro/operation/yaml/month.yaml +8512 -0
  47. data/lib/zakuro/output/response.rb +5 -5
  48. data/lib/zakuro/tools/typeconv.rb +38 -0
  49. data/lib/zakuro/tools/typeof.rb +4 -1
  50. data/lib/zakuro/version/context.rb +25 -4
  51. data/lib/zakuro/version/daien/const/number.rb +55 -0
  52. data/lib/zakuro/version/daien/const/remainder.rb +53 -0
  53. data/lib/zakuro/version/daien/cycle/remainder.rb +85 -0
  54. data/lib/zakuro/version/daien/cycle/solar_term.rb +34 -0
  55. data/lib/zakuro/version/daien/daien.rb +11 -0
  56. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +106 -0
  57. data/lib/zakuro/version/daien/range/annual_range.rb +39 -0
  58. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +240 -0
  59. data/lib/zakuro/version/daien/stella/lunar/localization.rb +44 -0
  60. data/lib/zakuro/version/daien/stella/lunar/location.rb +80 -0
  61. data/lib/zakuro/version/daien/stella/lunar/value.rb +75 -0
  62. data/lib/zakuro/version/daien/stella/origin/average_november.rb +34 -0
  63. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +62 -0
  64. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +55 -0
  65. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +93 -0
  66. data/lib/zakuro/version/daien/stella/solar/average.rb +98 -0
  67. data/lib/zakuro/version/daien/stella/solar/interval.rb +108 -0
  68. data/lib/zakuro/version/daien/stella/solar/location.rb +61 -0
  69. data/lib/zakuro/version/daien/stella/solar/value.rb +36 -0
  70. data/lib/zakuro/version/genka/const/number.rb +43 -0
  71. data/lib/zakuro/version/genka/const/remainder.rb +33 -0
  72. data/lib/zakuro/version/genka/cycle/remainder.rb +92 -0
  73. data/lib/zakuro/version/genka/cycle/solar_term.rb +34 -0
  74. data/lib/zakuro/version/genka/genka.rb +1 -9
  75. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +95 -0
  76. data/lib/zakuro/version/genka/range/annual_range.rb +77 -0
  77. data/lib/zakuro/version/genka/stella/origin/first_term.rb +55 -0
  78. data/lib/zakuro/version/genka/stella/origin/january.rb +49 -0
  79. data/lib/zakuro/version/genka/stella/solar/average.rb +41 -0
  80. data/lib/zakuro/version/gihou/const/remainder.rb +0 -2
  81. data/lib/zakuro/version/gihou/cycle/remainder.rb +27 -6
  82. data/lib/zakuro/version/gihou/gihou.rb +1 -30
  83. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +1 -1
  84. data/lib/zakuro/version/gihou/stella/lunar/location.rb +2 -8
  85. data/lib/zakuro/version/gihou/stella/lunar/value.rb +3 -2
  86. data/lib/zakuro/version/gihou/stella/solar/average.rb +3 -3
  87. data/lib/zakuro/version/gregorio/gregorio.rb +1 -9
  88. data/lib/zakuro/version/houryaku/houryaku.rb +1 -9
  89. data/lib/zakuro/version/joukyou/joukyou.rb +1 -9
  90. data/lib/zakuro/version/kansei/kansei.rb +1 -9
  91. data/lib/zakuro/version/senmyou/const/remainder.rb +0 -2
  92. data/lib/zakuro/version/senmyou/cycle/remainder.rb +27 -6
  93. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +1 -1
  94. data/lib/zakuro/version/senmyou/senmyou.rb +1 -30
  95. data/lib/zakuro/version/senmyou/stella/lunar/location.rb +2 -8
  96. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +3 -2
  97. data/lib/zakuro/version/senmyou/stella/solar/average.rb +3 -3
  98. data/lib/zakuro/version/tenpou/tenpou.rb +1 -9
  99. data/lib/zakuro/version/version_class_resolver.rb +8 -0
  100. data/zakuro.gemspec +1 -3
  101. metadata +50 -14
  102. data/lib/zakuro/calculation/base/multi_gengou.rb +0 -101
  103. data/lib/zakuro/calculation/base/multi_gengou_roller.rb +0 -218
  104. data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +0 -82
  105. data/lib/zakuro/era/japan/reki.rb +0 -91
  106. data/lib/zakuro/era/japan/yaml/set-001-until-south.yaml +0 -1121
  107. data/lib/zakuro/era/japan/yaml/set-002-from-north.yaml +0 -485
  108. data/lib/zakuro/era/japan/yaml/set-003-modern.yaml +0 -28
  109. data/lib/zakuro/version/abstract_version.rb +0 -29
  110. data/lib/zakuro/version/taien/taien.rb +0 -19
  111. data/lib/zakuro/version.rb +0 -7
  112. data/lib/zakuro/version_factory.rb +0 -59
@@ -56,7 +56,7 @@ module Zakuro
56
56
  date = param.date
57
57
  days = param.days
58
58
  Result::Data::SingleDay.new(
59
- year: save_year(year: year),
59
+ year: save_year(year: year, month: month, date: date),
60
60
  month: save_month(month: month, date: date, days: days),
61
61
  day: save_day(month: month, date: date, days: days)
62
62
  )
@@ -69,10 +69,10 @@ module Zakuro
69
69
  #
70
70
  # @return [Result::Year] 年データ
71
71
  #
72
- def self.save_year(year:)
73
- multi_gengou = year.multi_gengou
74
- first = multi_gengou.first_line
75
- second = multi_gengou.second_line
72
+ def self.save_year(year:, month:, date:)
73
+ gengou = month.gengou
74
+ first = gengou.match_first_line(date: date)
75
+ second = gengou.match_second_line(date: date)
76
76
  Result::Data::Year.new(
77
77
  first_gengou:
78
78
  Result::Data::Gengou.new(name: first.name, number: first.year),
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../output/logger'
4
+
5
+ # :nodoc:
6
+ module Zakuro
7
+ #
8
+ # Tools 汎用メソッド群
9
+ #
10
+ module Tools
11
+ # :reek:UncommunicativeVariableName {accept: e}
12
+
13
+ #
14
+ # Typeconv 型変換
15
+ #
16
+ module Typeconv
17
+ LOGGER = Output::Logger.new(location: 'Typeconv')
18
+
19
+ #
20
+ # 文字列を10進数で数値化する
21
+ #
22
+ # @param [String] text 対象文字列
23
+ # @param [Integer] default デフォルト数値
24
+ #
25
+ # @return [Integer] 数値
26
+ #
27
+ def self.to_i(text:, default:)
28
+ begin
29
+ return Integer(text, 10)
30
+ rescue StandardError => e
31
+ LOGGER.debug(e)
32
+ end
33
+
34
+ default
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../calculation/cycle/abstract_remainder'
4
- require_relative '../era/western'
4
+ require_relative '../era/japan/calendar'
5
+ require_relative '../era/western/calendar'
5
6
 
6
7
  # :nodoc:
7
8
  module Zakuro
@@ -22,6 +23,8 @@ module Zakuro
22
23
  # @return [False] 時間型ではない
23
24
  #
24
25
  def self.time?(obj:)
26
+ return true if obj.is_a?(Japan::Calendar)
27
+
25
28
  return true if obj.is_a?(Western::Calendar)
26
29
 
27
30
  return true if obj.is_a?(Calculation::Cycle::AbstractRemainder)
@@ -8,16 +8,37 @@ module Zakuro
8
8
  # Context 暦コンテキスト
9
9
  #
10
10
  class Context
11
+ # @return [String] 暦名
11
12
  attr_reader :version_name
13
+ # @return [VersionClassResolver] 暦リゾルバー
12
14
  attr_reader :resolver
13
15
 
14
- VERSION_NAMES = %w[Genka Gihou Taien Senmyou Joukyou Kansei Tenpou Gregorio].freeze
15
-
16
- def initialize(version_name:)
17
- raise ArgumentError.new, 'invalid version' unless VERSION_NAMES.include?(version_name)
16
+ # @return [Array<String>] 暦名
17
+ VERSION_NAMES = %w[Genka Gihou Daien Senmyou Joukyou Kansei Tenpou Gregorio].freeze
18
18
 
19
+ #
20
+ # 初期化
21
+ #
22
+ # @param [String] version_name 暦名
23
+ #
24
+ def initialize(version_name: '')
19
25
  @version_name = version_name
26
+
27
+ if !invalid? && !VERSION_NAMES.include?(version_name)
28
+ raise ArgumentError.new, 'invalid version'
29
+ end
30
+
20
31
  @resolver = VersionClassResolver.new(version_name: version_name)
21
32
  end
33
+
34
+ #
35
+ # 不正か
36
+ #
37
+ # @return [True] 不正
38
+ # @return [False] 不正なし
39
+ #
40
+ def invalid?
41
+ @version_name.empty?
42
+ end
22
43
  end
23
44
  end
@@ -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,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Zakuro
5
+ #
6
+ # Daien 大衍暦
7
+ #
8
+ module Daien
9
+ # none
10
+ end
11
+ 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