zakuro 0.1.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -1
  3. data/doc/gengou.md +22 -22
  4. data/doc/operation/csv/month.csv +468 -202
  5. data/doc/operation/operation.xlsx +0 -0
  6. data/lib/zakuro/calculation/base/operated_year.rb +114 -0
  7. data/lib/zakuro/calculation/base/year.rb +3 -0
  8. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +29 -29
  9. data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +169 -0
  10. data/lib/zakuro/calculation/monthly/first_day.rb +1 -1
  11. data/lib/zakuro/calculation/monthly/operated_month.rb +47 -3
  12. data/lib/zakuro/calculation/range/medieval_annual_range.rb +105 -0
  13. data/lib/zakuro/calculation/range/operated_range.rb +61 -16
  14. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +78 -0
  15. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +71 -0
  16. data/lib/zakuro/calculation/stella/solar/abstract_average.rb +117 -0
  17. data/lib/zakuro/calculation/stella/solar/abstract_location.rb +187 -0
  18. data/lib/zakuro/calculation/stella/solar/choukei_value.rb +136 -0
  19. data/lib/zakuro/calculation/type/old_float.rb +69 -0
  20. data/lib/zakuro/era/japan/reki.rb +1 -1
  21. data/lib/zakuro/era/japan/yaml/set-001-until-south.yaml +22 -22
  22. data/lib/zakuro/operation/month/type.rb +58 -0
  23. data/lib/zakuro/operation/yaml/month.yaml +8512 -0
  24. data/lib/zakuro/version/context.rb +1 -1
  25. data/lib/zakuro/version/daien/const/number.rb +55 -0
  26. data/lib/zakuro/version/daien/const/remainder.rb +53 -0
  27. data/lib/zakuro/version/daien/cycle/remainder.rb +85 -0
  28. data/lib/zakuro/version/daien/cycle/solar_term.rb +34 -0
  29. data/lib/zakuro/version/daien/daien.rb +36 -0
  30. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +106 -0
  31. data/lib/zakuro/version/daien/range/annual_range.rb +39 -0
  32. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +240 -0
  33. data/lib/zakuro/version/daien/stella/lunar/localization.rb +44 -0
  34. data/lib/zakuro/version/daien/stella/lunar/location.rb +80 -0
  35. data/lib/zakuro/version/daien/stella/lunar/value.rb +75 -0
  36. data/lib/zakuro/version/daien/stella/origin/average_november.rb +34 -0
  37. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +62 -0
  38. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +55 -0
  39. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +93 -0
  40. data/lib/zakuro/version/daien/stella/solar/average.rb +98 -0
  41. data/lib/zakuro/version/daien/stella/solar/interval.rb +108 -0
  42. data/lib/zakuro/version/daien/stella/solar/location.rb +61 -0
  43. data/lib/zakuro/version/daien/stella/solar/value.rb +36 -0
  44. data/lib/zakuro/version/genka/const/number.rb +43 -0
  45. data/lib/zakuro/version/genka/const/remainder.rb +33 -0
  46. data/lib/zakuro/version/genka/cycle/remainder.rb +92 -0
  47. data/lib/zakuro/version/genka/cycle/solar_term.rb +34 -0
  48. data/lib/zakuro/version/genka/genka.rb +19 -2
  49. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +95 -0
  50. data/lib/zakuro/version/genka/range/annual_range.rb +77 -0
  51. data/lib/zakuro/version/genka/stella/origin/first_term.rb +55 -0
  52. data/lib/zakuro/version/genka/stella/origin/january.rb +49 -0
  53. data/lib/zakuro/version/genka/stella/solar/average.rb +41 -0
  54. data/lib/zakuro/version/gihou/const/number.rb +55 -0
  55. data/lib/zakuro/version/gihou/const/remainder.rb +54 -0
  56. data/lib/zakuro/version/gihou/cycle/remainder.rb +82 -0
  57. data/lib/zakuro/version/gihou/cycle/solar_term.rb +34 -0
  58. data/lib/zakuro/version/gihou/gihou.rb +23 -2
  59. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +106 -0
  60. data/lib/zakuro/version/gihou/range/annual_range.rb +39 -0
  61. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +250 -0
  62. data/lib/zakuro/version/gihou/stella/lunar/localization.rb +44 -0
  63. data/lib/zakuro/version/gihou/stella/lunar/location.rb +80 -0
  64. data/lib/zakuro/version/gihou/stella/lunar/value.rb +75 -0
  65. data/lib/zakuro/version/gihou/stella/origin/average_november.rb +34 -0
  66. data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +62 -0
  67. data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +55 -0
  68. data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +93 -0
  69. data/lib/zakuro/version/gihou/stella/solar/average.rb +97 -0
  70. data/lib/zakuro/version/gihou/stella/solar/interval.rb +108 -0
  71. data/lib/zakuro/version/gihou/stella/solar/location.rb +61 -0
  72. data/lib/zakuro/version/gihou/stella/solar/value.rb +36 -0
  73. data/lib/zakuro/version/senmyou/const/number.rb +1 -1
  74. data/lib/zakuro/version/senmyou/const/remainder.rb +7 -3
  75. data/lib/zakuro/version/senmyou/cycle/remainder.rb +27 -6
  76. data/lib/zakuro/version/senmyou/cycle/solar_term.rb +4 -1
  77. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +12 -112
  78. data/lib/zakuro/version/senmyou/range/annual_range.rb +5 -77
  79. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +2 -3
  80. data/lib/zakuro/version/senmyou/stella/lunar/location.rb +13 -34
  81. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +8 -30
  82. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +29 -29
  83. data/lib/zakuro/version/senmyou/stella/solar/average.rb +14 -92
  84. data/lib/zakuro/version/senmyou/stella/solar/location.rb +18 -121
  85. data/lib/zakuro/version/senmyou/stella/solar/value.rb +4 -103
  86. data/lib/zakuro/version/version_class_resolver.rb +12 -0
  87. data/lib/zakuro/version.rb +1 -1
  88. data/lib/zakuro/version_factory.rb +1 -1
  89. metadata +61 -7
  90. data/lib/zakuro/version/taien/taien.rb +0 -19
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../../calculation/stella/solar/abstract_location'
4
+
5
+ require_relative '../../const/remainder'
6
+
7
+ require_relative './interval'
8
+
9
+ # :nodoc:
10
+ module Zakuro
11
+ # :nodoc:
12
+ module Daien
13
+ # :nodoc:
14
+ module Solar
15
+ #
16
+ # Location 入定気
17
+ #
18
+ class Location < Calculation::Solar::AbstractLocation
19
+ # @return [Cycle::Remainder] 弦
20
+ QUARTER = Const::Remainder::Solar::QUARTER
21
+
22
+ #
23
+ # 初期化
24
+ #
25
+ # @param [Cycle::Remainder] lunar_age 天正閏余(大余小余)
26
+ #
27
+ def initialize(lunar_age:)
28
+ super(lunar_age: lunar_age, quarter: QUARTER)
29
+ end
30
+
31
+ # :reek:UtilityFunction
32
+
33
+ #
34
+ # 二十四節気番号に対応する入気定日加減数を返す
35
+ #
36
+ # @note 継承のためクラスメソッドにしない
37
+ #
38
+ # @param [Integer] index 二十四節気番号
39
+ #
40
+ # @return [Cycle::Remainder] 入気定日加減数
41
+ #
42
+ def interval(index:)
43
+ Interval.index_of(index)
44
+ end
45
+
46
+ # :reek:UtilityFunction
47
+
48
+ #
49
+ # 入気定日加減数の要素数を返す
50
+ #
51
+ # @note 継承のためクラスメソッドにしない
52
+ #
53
+ # @return [Integer] 入気定日加減数の要素数
54
+ #
55
+ def interval_size
56
+ Interval.size
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../../calculation/stella/solar/choukei_value'
4
+
5
+ require_relative '../../const/number'
6
+
7
+ require_relative './adjustment'
8
+
9
+ # :nodoc:
10
+ module Zakuro
11
+ # :nodoc:
12
+ module Daien
13
+ # :nodoc:
14
+ module Solar
15
+ #
16
+ # Value 太陽補正値
17
+ #
18
+ module Value
19
+ #
20
+ # 太陽の運行による補正値を算出する
21
+ #
22
+ # @param [SolarTerm] solar_location 入定気
23
+ #
24
+ # @return [Integer] 補正値
25
+ #
26
+ def self.get(solar_location:)
27
+ remainder = solar_location.remainder
28
+
29
+ row = Adjustment.specify(index: solar_location.index)
30
+
31
+ Calculation::Solar::ChoukeiValue.get(remainder: remainder, row: row)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Zakuro
5
+ # :nodoc:
6
+ module Genka
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日=752分)
20
+ DAY = 752
21
+ # @return [Integer] 度法(1日=304分)
22
+ TERM_DAY = 304
23
+ # @return [Integer] 朔望月
24
+ SYNODIC_MONTH = 22_207
25
+ end
26
+
27
+ #
28
+ # 累積
29
+ #
30
+ module Stack
31
+ # @return [Integer] 積年(甲子夜半朔旦冬至〜暦の開始前)
32
+ TOTAL_YEAR = 5703
33
+ # @return [Integer] 暦の開始年(元嘉20年)
34
+ BEGIN_YEAR = 443
35
+ # @return [Integer] 西暦0年の積年
36
+ WESTERN_YEAR = 1612
37
+ # @return [Integer] 余数
38
+ YEAR_REMAINDER = 1595
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../cycle/remainder'
4
+
5
+ # :nodoc:
6
+ module Zakuro
7
+ # :nodoc:
8
+ module Genka
9
+ #
10
+ # Const 定数
11
+ #
12
+ module Const
13
+ #
14
+ # Remainder 大余小余
15
+ #
16
+ module Remainder
17
+ #
18
+ # @note 『歴代天文律暦等志彙編 六』中華書房 p.1727
19
+ # 「推弦望法..加朔大餘七,小餘二百八十七,小分三,小分満四從小餘」
20
+ #
21
+ # @return [Cycle::Remainder] 弦(1分=4秒)
22
+ QUARTER = Cycle::Remainder.new(day: 7, minute: 287, second: 3)
23
+
24
+ #
25
+ # @note 『歴代天文律暦等志彙編 六』中華書房 p.1727
26
+ # 「推二十四氣術」「求次氣,加朔大餘十五,小餘六十六,小分十一,小分満氣法從小餘,小餘満度法從大餘」
27
+ #
28
+ # @return [Cycle::Remainder] 気策(24分の1年)
29
+ SOLAR_TERM_AVERAGE = Cycle::TermRemainder.new(day: 15, minute: 66 + 11.0 / 24, second: 0)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,92 @@
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 Genka
11
+ # :nodoc:
12
+ module Cycle
13
+ #
14
+ # Remainder 時刻情報(大余小余)
15
+ #
16
+ class Remainder < Calculation::Cycle::AbstractRemainder
17
+ #
18
+ # @note 『歴代天文律暦等志彙編 六』中華書房 p.1727
19
+ # 「推弦望法..加朔大餘七,小餘二百八十七,小分三,小分満四從小餘」
20
+ #
21
+ # @return [Integer] 分(1分=4秒)
22
+ MINUTE = 4
23
+
24
+ #
25
+ # 初期化
26
+ #
27
+ # @param [Integer] day 大余("日"に相当)
28
+ # @param [Integer] minute 小余("分"に相当)
29
+ # @param [Integer] second 秒
30
+ # @param [Integer] total 繰り上げなしの小余
31
+ #
32
+ def initialize(day: -1, minute: -1, second: -1, total: -1)
33
+ super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
34
+ day: day, minute: minute, second: second, total: total)
35
+ end
36
+
37
+ #
38
+ # 特定の文字フォーマットにして出力する
39
+ #
40
+ # @return [String] フォーマットした結果
41
+ #
42
+ def format(form: '%.4f', digit: 4)
43
+ return '' if invalid?
44
+
45
+ decimal = @day + @minute / @base_day.to_f
46
+ super(form, decimal.round(digit))
47
+ end
48
+ end
49
+
50
+ #
51
+ # TermRemainder 時刻情報(大余小余)
52
+ #
53
+ class TermRemainder < Calculation::Cycle::AbstractRemainder
54
+ #
55
+ # @note 『歴代天文律暦等志彙編 六』中華書房 p.1726
56
+ # 「氣法,二十四」
57
+ #
58
+ # @return [Integer] 分(1分=24秒)
59
+ MINUTE = 24
60
+
61
+ #
62
+ # 初期化
63
+ #
64
+ # @param [Integer] day 大余("日"に相当)
65
+ # @param [Integer] minute 小余("分"に相当)
66
+ # @param [Integer] second 秒
67
+ # @param [Integer] total 繰り上げなしの小余
68
+ #
69
+ def initialize(day: -1, minute: -1, second: -1, total: -1)
70
+ super(base_day: Const::Number::Cycle::TERM_DAY, base_mitune: MINUTE,
71
+ day: day, minute: minute, second: second, total: total)
72
+ end
73
+
74
+ #
75
+ # 特定の文字フォーマットにして出力する
76
+ #
77
+ # @return [String] フォーマットした結果
78
+ #
79
+ def format(form: '%.4f', digit: 4)
80
+ return '' if invalid?
81
+
82
+ decimal = @day + @minute / @base_day.to_f
83
+ # NOTE: roundなしで format を使用した場合は、四捨五入が正しく実行されないことが判明した
84
+ # 具体的には、468年の中気は '55.7813' だが '55.7812' になる
85
+ # これは '55.7812500' を4桁にした際に、境界値の少数点以下5桁目の '5' が切り捨てを受けたためである
86
+ # format による四捨五入は避け、roundによる四捨五入を採用する
87
+ super(form, decimal.round(digit))
88
+ end
89
+ end
90
+ end
91
+ end
92
+ 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 Genka
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_TERM_AVERAGE
21
+
22
+ #
23
+ # 初期化
24
+ #
25
+ # @param [Integer] index 連番
26
+ # @param [Remainder] remainder 時刻情報(大余小余)
27
+ #
28
+ def initialize(index: -1, remainder: TermRemainder.new)
29
+ super(index: index, remainder: remainder, average: SOLAR_TERM_AVERAGE)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -12,8 +12,25 @@ module Zakuro
12
12
  # Gateway アクセサメソッド群
13
13
  #
14
14
  class Gateway < AbstractVersion
15
- # @return [False] リリースなし
16
- RELEASE = false
15
+ # @return [True] リリースあり
16
+ RELEASE = true
17
+
18
+ # @return [String] 暦クラス名
19
+ VERSION_NAME = 'Genka'
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
17
34
  end
18
35
  end
19
36
  end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../const/remainder'
4
+
5
+ require_relative '../cycle/solar_term'
6
+
7
+ require_relative '../stella/origin/first_term'
8
+
9
+ require_relative '../stella/origin/january'
10
+
11
+ # :nodoc:
12
+ module Zakuro
13
+ # :nodoc:
14
+ module Genka
15
+ # :nodoc:
16
+ module Monthly
17
+ #
18
+ # LunarPhase 月の位相
19
+ #
20
+ class LunarPhase
21
+ # @return [Cycle::Remainder] 弦
22
+ QUARTER = Const::Remainder::QUARTER
23
+
24
+ # TODO: AbstractLunarPhase でも使用している
25
+
26
+ # @return [Array<String>] 月内の弦
27
+ PHASE_INDEXES = %w[朔日 上弦 望月 下弦].freeze
28
+
29
+ # @return [Cycle::AbstractRemainder] 経
30
+ attr_reader :remainder
31
+
32
+ #
33
+ # 初期化
34
+ #
35
+ # @param [Cycle::Remainder] remainder 正月経朔
36
+ #
37
+ def initialize(remainder:)
38
+ # 経
39
+ @remainder = remainder
40
+
41
+ # 弦の位置
42
+ @index = 0
43
+ end
44
+
45
+ #
46
+ # 次の弦に進める
47
+ #
48
+ # @return [Remainder] 定朔
49
+ #
50
+ def next_phase
51
+ adjusted = remainder.clone
52
+
53
+ add_quarter_moon_size
54
+
55
+ adjusted
56
+ end
57
+
58
+ #
59
+ # 次の月に進める
60
+ # @note 進めた後の月の定朔ではなく、当月のものを返却する
61
+ #
62
+ # @return [Remainder] 当月初の定朔
63
+ #
64
+ def next_month
65
+ result = nil
66
+ PHASE_INDEXES.each_with_index do |_phase, index|
67
+ adjust = next_phase
68
+ result = adjust if index.zero?
69
+ end
70
+
71
+ result
72
+ end
73
+
74
+ private
75
+
76
+ #
77
+ # 次の弦に進める
78
+ #
79
+ # @return [Integer] 弦
80
+ #
81
+ def next_index
82
+ @index += 1
83
+ @index = 0 if @index >= PHASE_INDEXES.size
84
+ @index
85
+ end
86
+
87
+ def add_quarter_moon_size
88
+ @remainder.add!(QUARTER)
89
+
90
+ next_index
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../calculation/range/medieval_annual_range'
4
+ require_relative '../../../output/logger'
5
+ require_relative '../monthly/lunar_phase'
6
+ require_relative '../stella/solar/average'
7
+
8
+ # :nodoc:
9
+ module Zakuro
10
+ # :nodoc:
11
+ module Genka
12
+ # :nodoc:
13
+ module Range
14
+ #
15
+ # AnnualRange 年間範囲
16
+ #
17
+ module AnnualRange
18
+ # @return [Output::Logger] ロガー
19
+ LOGGER = Output::Logger.new(location: 'annual_range')
20
+
21
+ #
22
+ # 一覧取得する
23
+ #
24
+ # * 対象年に対して、当年1月-翌年1月までを出力する
25
+ # * 対象年(西暦)と計算年(元号x年)の紐付けは行わない
26
+ #
27
+ # @param [Context] context 暦コンテキスト
28
+ # @param [Integer] western_year 西暦年
29
+ #
30
+ # @return [Array<Month>] 1年データ
31
+ #
32
+ def self.get(context:, western_year:)
33
+ # 正月中気
34
+ solar_term = Cycle::SolarTerm.new(
35
+ index: 4, remainder: Origin::FirstTerm.get(western_year: western_year)
36
+ )
37
+ # 正月に立春が含まれる可能性があるので、立春まで戻しておく
38
+ solar_term.prev_term!
39
+
40
+ # 経
41
+ remainder = Origin::January.get(western_year: western_year)
42
+
43
+ lunar_phase = Monthly::LunarPhase.new(remainder: remainder)
44
+
45
+ solar_average = Solar::Average.new(solar_term: solar_term)
46
+
47
+ annual_range = Calculation::Range::MedievalAnnualRange.get(
48
+ context: context, lunar_phase: lunar_phase, solar_average: solar_average
49
+ )
50
+
51
+ pop_months_on_next_year(annual_range: annual_range)
52
+ end
53
+
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
67
+
68
+ number = month.month_label.number
69
+ result.push(month)
70
+ end
71
+
72
+ result
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../const/number'
4
+ require_relative '../../cycle/remainder'
5
+
6
+ # :nodoc:
7
+ module Zakuro
8
+ # :nodoc:
9
+ module Genka
10
+ # :nodoc:
11
+ module Origin
12
+ #
13
+ # FirstTerm 年初の中気(正月中雨水)
14
+ #
15
+ module FirstTerm
16
+ # @return [Integer] 二十四節気の1日
17
+ TERM_DAY = Const::Number::Cycle::TERM_DAY
18
+ # @return [Float] 余数
19
+ YEAR_REMAINDER = Const::Number::Stack::YEAR_REMAINDER.to_f
20
+ # @return [Integer] 西暦0年の積年
21
+ WESTERN_YEAR = Const::Number::Stack::WESTERN_YEAR
22
+
23
+ #
24
+ # 年初の中気(正月中雨水)を求める
25
+ #
26
+ # @note 計算は宋書(1)に従う。念のため『日本暦日原典』(2)と比較する
27
+ # 1. (1612 + 西暦年) * 餘数(1595) / 度法(304) = A' ...余りが中気の小余
28
+ # A' / 60 = B' ...余りが朔の大余
29
+ # 『歴代天文律暦等志彙編 六』中華書房 p.1728
30
+ #
31
+ # 2. (1612 + x) * 222070 / 608 = A' ...余りが中気の小余
32
+ # A' / 60 = B' ...余りが朔の大余
33
+ #
34
+ # 小余上限(度法)の違いで、宋書に従ったほうが良いと判断した。分母が変わるだけで結果に相違はない
35
+ #
36
+ # @param [Integer] western_year 西暦年
37
+ #
38
+ # @return [Remainder] 年初の中気(正月中雨水)
39
+ #
40
+ def self.get(western_year:)
41
+ total_western_year = WESTERN_YEAR + western_year
42
+ # (1612 + x) * 222070 / 608 = A' ...余りが中気の小余
43
+ stack = (total_western_year * YEAR_REMAINDER / TERM_DAY).to_i
44
+ minute = (total_western_year * YEAR_REMAINDER % TERM_DAY).to_i
45
+ # A' / 60 = B' ...余りが朔の大余
46
+ day = stack % Cycle::TermRemainder::LIMIT
47
+ # p stack
48
+ # p minute
49
+ # p day
50
+ Cycle::TermRemainder.new(day: day, minute: minute, second: 0)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../const/number'
4
+ require_relative '../../cycle/remainder'
5
+
6
+ # :nodoc:
7
+ module Zakuro
8
+ # :nodoc:
9
+ module Genka
10
+ # :nodoc:
11
+ module Origin
12
+ #
13
+ # January 1月
14
+ #
15
+ module January
16
+ # @return [Integer] 日法
17
+ DAY = Const::Number::Cycle::DAY
18
+ # @return [Float] 朔望月
19
+ SYNODIC_MONTH = Const::Number::Cycle::SYNODIC_MONTH.to_f
20
+ # @return [Integer] 西暦0年の積年
21
+ WESTERN_YEAR = Const::Number::Stack::WESTERN_YEAR
22
+ # @return [Float] 19年=235朔望月
23
+ METONIC_CYCLE = 235 / 19.to_f
24
+
25
+ #
26
+ # 1月経朔を求める
27
+ #
28
+ # @param [Integer] western_year 西暦年
29
+ #
30
+ # @return [Remainder] 11月経朔
31
+ #
32
+ def self.get(western_year:)
33
+ # (1612 + x) * 235 / 19 = A ...余り
34
+ stack = ((WESTERN_YEAR + western_year) * METONIC_CYCLE).to_i
35
+ # A * 22207 / 752 = B ...余りが朔の小余
36
+ minute_total = (stack * SYNODIC_MONTH / DAY).to_i
37
+ minute = (stack * SYNODIC_MONTH % DAY).to_i
38
+ # B / 60 = C ...余りが朔の大余
39
+ day = minute_total % Cycle::Remainder::LIMIT
40
+ # p stack
41
+ # p minute_total
42
+ # p minute
43
+ # p day
44
+ Cycle::Remainder.new(day: day, minute: minute, second: 0)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../../calculation/stella/solar/abstract_average'
4
+
5
+ require_relative '../../const/remainder'
6
+
7
+ require_relative '../../cycle/solar_term'
8
+
9
+ # :nodoc:
10
+ module Zakuro
11
+ # :nodoc:
12
+ module Genka
13
+ # :nodoc:
14
+ module Solar
15
+ #
16
+ # Average 平気(太陽軌道平均)
17
+ #
18
+ class Average < Calculation::Solar::AbstractAverage
19
+ #
20
+ # 初期化
21
+ #
22
+ # @param [Integer] western_year 西暦年
23
+ #
24
+ def initialize(solar_term:)
25
+ super(solar_term: solar_term)
26
+ end
27
+
28
+ #
29
+ # 冬至から数えた1年データの月ごとに二十四節気を割り当てる
30
+ #
31
+ # @param [Array<Month>] annual_range 1年データ
32
+ #
33
+ # @return [Array<Month>] 1年データ
34
+ #
35
+ def set(annual_range:)
36
+ super(annual_range: annual_range)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end