zakuro 0.2.0 → 0.6.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/VERSION +1 -0
- 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/gengou.rb +82 -0
- data/lib/zakuro/calculation/base/linear_gengou.rb +76 -0
- data/lib/zakuro/calculation/base/operated_year.rb +104 -0
- data/lib/zakuro/calculation/base/year.rb +28 -13
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +29 -29
- data/lib/zakuro/calculation/gengou/internal/counter.rb +129 -0
- data/lib/zakuro/calculation/gengou/internal/reserve/interval.rb +183 -0
- data/lib/zakuro/calculation/gengou/internal/reserve/list.rb +382 -0
- data/lib/zakuro/calculation/gengou/internal/reserve.rb +42 -0
- data/lib/zakuro/calculation/gengou/scroll.rb +262 -0
- data/lib/zakuro/calculation/monthly/first_day.rb +3 -2
- data/lib/zakuro/calculation/monthly/month.rb +49 -2
- data/lib/zakuro/calculation/monthly/operated_month.rb +49 -5
- data/lib/zakuro/calculation/range/full_range.rb +65 -103
- data/lib/zakuro/calculation/range/operated_range.rb +73 -23
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +36 -17
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +54 -0
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +25 -21
- data/lib/zakuro/calculation/specifier/single_day.rb +13 -35
- data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +9 -7
- data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +19 -0
- data/lib/zakuro/calculation/summary/single.rb +5 -2
- data/lib/zakuro/calculation/version/internal/crawler.rb +51 -0
- data/lib/zakuro/calculation/version/internal/range.rb +39 -0
- data/lib/zakuro/calculation/version/version.rb +24 -0
- data/lib/zakuro/era/japan/calendar.rb +133 -0
- data/lib/zakuro/era/japan/gengou/parser.rb +95 -25
- data/lib/zakuro/era/japan/gengou/type.rb +148 -41
- data/lib/zakuro/era/japan/gengou/validator.rb +157 -52
- data/lib/zakuro/era/japan/gengou/yaml/set-001-until-south.yaml +1870 -0
- data/lib/zakuro/era/japan/gengou/yaml/set-002-from-north.yaml +810 -0
- data/lib/zakuro/era/japan/gengou/yaml/set-003-modern.yaml +50 -0
- data/lib/zakuro/era/japan/gengou.rb +5 -5
- data/lib/zakuro/era/japan/version.rb +151 -0
- data/lib/zakuro/era/{western.rb → western/calendar.rb} +0 -0
- data/lib/zakuro/merchant.rb +12 -3
- data/lib/zakuro/operation/month/parser.rb +1 -1
- data/lib/zakuro/operation/month/type.rb +59 -1
- data/lib/zakuro/operation/month/validator.rb +1 -1
- data/lib/zakuro/operation/yaml/month.yaml +8512 -0
- data/lib/zakuro/output/response.rb +5 -5
- data/lib/zakuro/tools/typeconv.rb +38 -0
- data/lib/zakuro/tools/typeof.rb +4 -1
- data/lib/zakuro/version/context.rb +25 -4
- 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 +11 -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 +1 -9
- 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/remainder.rb +0 -2
- data/lib/zakuro/version/gihou/cycle/remainder.rb +27 -6
- data/lib/zakuro/version/gihou/gihou.rb +1 -30
- data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +1 -1
- data/lib/zakuro/version/gihou/stella/lunar/location.rb +2 -8
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +3 -2
- data/lib/zakuro/version/gihou/stella/solar/average.rb +3 -3
- data/lib/zakuro/version/gregorio/gregorio.rb +1 -9
- data/lib/zakuro/version/houryaku/houryaku.rb +1 -9
- data/lib/zakuro/version/joukyou/joukyou.rb +1 -9
- data/lib/zakuro/version/kansei/kansei.rb +1 -9
- data/lib/zakuro/version/senmyou/const/remainder.rb +0 -2
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +27 -6
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +1 -1
- data/lib/zakuro/version/senmyou/senmyou.rb +1 -30
- data/lib/zakuro/version/senmyou/stella/lunar/location.rb +2 -8
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +3 -2
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +3 -3
- data/lib/zakuro/version/tenpou/tenpou.rb +1 -9
- data/lib/zakuro/version/version_class_resolver.rb +8 -0
- data/zakuro.gemspec +1 -3
- metadata +50 -14
- data/lib/zakuro/calculation/base/multi_gengou.rb +0 -101
- data/lib/zakuro/calculation/base/multi_gengou_roller.rb +0 -218
- data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +0 -82
- data/lib/zakuro/era/japan/reki.rb +0 -91
- data/lib/zakuro/era/japan/yaml/set-001-until-south.yaml +0 -1121
- data/lib/zakuro/era/japan/yaml/set-002-from-north.yaml +0 -485
- data/lib/zakuro/era/japan/yaml/set-003-modern.yaml +0 -28
- data/lib/zakuro/version/abstract_version.rb +0 -29
- data/lib/zakuro/version/taien/taien.rb +0 -19
- data/lib/zakuro/version.rb +0 -7
- data/lib/zakuro/version_factory.rb +0 -59
@@ -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
|
@@ -36,8 +36,6 @@ module Zakuro
|
|
36
36
|
# @return [Cycle::LunarRemainder] 変日(1近点月)
|
37
37
|
ANOMALISTIC_MONTH = \
|
38
38
|
Cycle::LunarRemainder.new(day: 27, minute: 743, second: 1)
|
39
|
-
# @return [Cycle::LunarRemainder] 入暦上限
|
40
|
-
LIMIT = Cycle::LunarRemainder.new(day: 28, minute: 743, second: 0)
|
41
39
|
#
|
42
40
|
# @note 常朔実 39571 = 29-711
|
43
41
|
# * 39571 / 4 = 9892.75 / 1340 = 7 余り 512.75
|
@@ -11,12 +11,7 @@ module Zakuro
|
|
11
11
|
# :nodoc:
|
12
12
|
module Cycle
|
13
13
|
#
|
14
|
-
# Remainder
|
15
|
-
#
|
16
|
-
# * 「15日1012分5秒」のような形式で表される
|
17
|
-
# * 分は1340で一日に繰り上げる
|
18
|
-
# * 秒は基本的に1/6分で、6秒で1分に繰り上げる。ただし、月補正値は1分に100秒とするなど基数の変更がありえる
|
19
|
-
# * 十干十二支(60日)を上限とした「日時分秒」の情報で、日付(date)/時刻(time)と部分的に重なる概念
|
14
|
+
# Remainder 時刻情報(大余小余)
|
20
15
|
#
|
21
16
|
class Remainder < Calculation::Cycle::AbstractRemainder
|
22
17
|
# @return [Integer] 分(1分=6秒)
|
@@ -34,6 +29,19 @@ module Zakuro
|
|
34
29
|
super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
|
35
30
|
day: day, minute: minute, second: second, total: total)
|
36
31
|
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# 特定の文字フォーマットにして出力する
|
35
|
+
#
|
36
|
+
# @param [String] form フォーマット(大余、小余、秒それぞれを%dで指定する)
|
37
|
+
#
|
38
|
+
# @return [String] フォーマットした結果
|
39
|
+
#
|
40
|
+
def format(form: '%d-%d')
|
41
|
+
return '' if invalid?
|
42
|
+
|
43
|
+
super(form, @day, @minute, @second)
|
44
|
+
end
|
37
45
|
end
|
38
46
|
|
39
47
|
#
|
@@ -55,6 +63,19 @@ module Zakuro
|
|
55
63
|
super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
|
56
64
|
day: day, minute: minute, second: second, total: total)
|
57
65
|
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# 特定の文字フォーマットにして出力する
|
69
|
+
#
|
70
|
+
# @param [String] form フォーマット(大余、小余、秒それぞれを%dで指定する)
|
71
|
+
#
|
72
|
+
# @return [String] フォーマットした結果
|
73
|
+
#
|
74
|
+
def format(form: '%d-%d')
|
75
|
+
return '' if invalid?
|
76
|
+
|
77
|
+
super(form, @day, @minute, @second)
|
78
|
+
end
|
58
79
|
end
|
59
80
|
end
|
60
81
|
end
|
@@ -1,40 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'date'
|
4
|
-
require_relative '../../era/western'
|
5
|
-
require_relative '../abstract_version'
|
6
|
-
require_relative '../context'
|
7
|
-
require_relative '../../calculation/summary/single'
|
8
|
-
|
9
3
|
# :nodoc:
|
10
4
|
module Zakuro
|
11
5
|
#
|
12
6
|
# Gihou 儀鳳暦
|
13
7
|
#
|
14
8
|
module Gihou
|
15
|
-
#
|
16
|
-
# Gateway アクセサメソッド群
|
17
|
-
#
|
18
|
-
class Gateway < AbstractVersion
|
19
|
-
# @return [True] リリースあり
|
20
|
-
RELEASE = true
|
21
|
-
|
22
|
-
# @return [String] 暦クラス名
|
23
|
-
VERSION_NAME = 'Gihou'
|
24
|
-
|
25
|
-
#
|
26
|
-
# 西暦日から和暦日に変換する
|
27
|
-
#
|
28
|
-
# @param [Date] western_date 西暦日
|
29
|
-
#
|
30
|
-
# @return [Result::Single] 和暦日
|
31
|
-
#
|
32
|
-
def self.to_japan_date(western_date:)
|
33
|
-
date = Western::Calendar.create(date: western_date)
|
34
|
-
|
35
|
-
context = Context.new(version_name: VERSION_NAME)
|
36
|
-
Calculation::Summary::Single.get(context: context, date: date)
|
37
|
-
end
|
38
|
-
end
|
9
|
+
# none
|
39
10
|
end
|
40
11
|
end
|
@@ -92,7 +92,7 @@ module Zakuro
|
|
92
92
|
def correction_moon_value
|
93
93
|
@lunar_location.run
|
94
94
|
|
95
|
-
remainder = @lunar_location.
|
95
|
+
remainder = @lunar_location.adjusted_remainder
|
96
96
|
|
97
97
|
# debug("[lunar]remainder.format: #{remainder.format(form: '%d-%d-%.5f')}")
|
98
98
|
# debug("[lunar]remainder.day: #{remainder.day}")
|
@@ -18,8 +18,6 @@ module Zakuro
|
|
18
18
|
class Location < Calculation::Lunar::AbstractLocation
|
19
19
|
# @return [Cycle::LunarRemainder] 1近点月
|
20
20
|
ANOMALISTIC_MONTH = Const::Remainder::Lunar::ANOMALISTIC_MONTH
|
21
|
-
# @return [Cycle::LunarRemainder] 入暦上限
|
22
|
-
LIMIT = Const::Remainder::Lunar::LIMIT
|
23
21
|
# @return [Cycle::LunarRemainder] 弦
|
24
22
|
QUARTER = Const::Remainder::Lunar::QUARTER
|
25
23
|
|
@@ -38,8 +36,7 @@ module Zakuro
|
|
38
36
|
#
|
39
37
|
def run
|
40
38
|
if calculated
|
41
|
-
|
42
|
-
decrease(limit: LIMIT)
|
39
|
+
decrease(limit: ANOMALISTIC_MONTH)
|
43
40
|
return
|
44
41
|
end
|
45
42
|
|
@@ -62,10 +59,7 @@ module Zakuro
|
|
62
59
|
@remainder = Localization.first_remainder(
|
63
60
|
lunar_age: remainder, western_year: western_year
|
64
61
|
)
|
65
|
-
# 初回は0始まりで計算しているので、入暦上限ではなく1近点月を用いる
|
66
62
|
decrease(limit: ANOMALISTIC_MONTH)
|
67
|
-
# 1始まりに改める
|
68
|
-
one_based
|
69
63
|
|
70
64
|
@calculated = true
|
71
65
|
end
|
@@ -78,7 +72,7 @@ module Zakuro
|
|
78
72
|
def decrease(limit:)
|
79
73
|
return if remainder < limit
|
80
74
|
|
81
|
-
remainder.sub!(
|
75
|
+
remainder.sub!(limit)
|
82
76
|
end
|
83
77
|
end
|
84
78
|
end
|
@@ -31,8 +31,9 @@ module Zakuro
|
|
31
31
|
def self.get(remainder:)
|
32
32
|
valid?(remainder: remainder)
|
33
33
|
|
34
|
-
day =
|
35
|
-
|
34
|
+
day, minute = Calculation::Lunar::ChoukeiValue.remainder_without_second(
|
35
|
+
remainder: remainder
|
36
|
+
)
|
36
37
|
|
37
38
|
# 引き当て
|
38
39
|
row = Adjustment.specify(day: day, minute: minute)
|
@@ -55,7 +55,7 @@ module Zakuro
|
|
55
55
|
# 二十四節気(冬至)
|
56
56
|
solar_term = Cycle::SolarTerm.new(index: 0, remainder: winter_solstice)
|
57
57
|
|
58
|
-
first_solar_term_index = Average.
|
58
|
+
first_solar_term_index = Average.calc_first_solar_term_index(western_year: western_year)
|
59
59
|
|
60
60
|
# 対象の二十四節気まで戻す
|
61
61
|
solar_term.prev_by_index(first_solar_term_index)
|
@@ -77,7 +77,7 @@ module Zakuro
|
|
77
77
|
#
|
78
78
|
# @return [Integer] 二十四節気番号
|
79
79
|
#
|
80
|
-
def self.
|
80
|
+
def self.calc_first_solar_term_index(western_year:)
|
81
81
|
# 天正閏余
|
82
82
|
lunar_age = Origin::LunarAge.get(western_year: western_year)
|
83
83
|
|
@@ -87,7 +87,7 @@ module Zakuro
|
|
87
87
|
solar_term_index = solar_location.index
|
88
88
|
|
89
89
|
# 入定気の一つ後の二十四節気まで戻す(ただし11月経朔が二十四節気上にある場合は戻さない)
|
90
|
-
solar_term_index += 1 unless solar_location.remainder
|
90
|
+
solar_term_index += 1 unless solar_location.remainder.day.zero?
|
91
91
|
|
92
92
|
solar_term_index
|
93
93
|
end
|
@@ -1,19 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../abstract_version'
|
4
|
-
|
5
3
|
# :nodoc:
|
6
4
|
module Zakuro
|
7
5
|
#
|
8
6
|
# Gregorio グレゴリオ暦
|
9
7
|
#
|
10
8
|
module Gregorio
|
11
|
-
#
|
12
|
-
# Gateway アクセサメソッド群
|
13
|
-
#
|
14
|
-
class Gateway < AbstractVersion
|
15
|
-
# @return [False] リリースなし
|
16
|
-
RELEASE = false
|
17
|
-
end
|
9
|
+
# none
|
18
10
|
end
|
19
11
|
end
|
@@ -1,19 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../abstract_version'
|
4
|
-
|
5
3
|
# :nodoc:
|
6
4
|
module Zakuro
|
7
5
|
#
|
8
6
|
# Houryaku 宝暦暦
|
9
7
|
#
|
10
8
|
module Houryaku
|
11
|
-
#
|
12
|
-
# Gateway アクセサメソッド群
|
13
|
-
#
|
14
|
-
class Gateway < AbstractVersion
|
15
|
-
# @return [False] リリースなし
|
16
|
-
RELEASE = false
|
17
|
-
end
|
9
|
+
# none
|
18
10
|
end
|
19
11
|
end
|
@@ -1,19 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../abstract_version'
|
4
|
-
|
5
3
|
# :nodoc:
|
6
4
|
module Zakuro
|
7
5
|
#
|
8
6
|
# Joukyou 貞享暦
|
9
7
|
#
|
10
8
|
module Joukyou
|
11
|
-
#
|
12
|
-
# Gateway アクセサメソッド群
|
13
|
-
#
|
14
|
-
class Gateway < AbstractVersion
|
15
|
-
# @return [False] リリースなし
|
16
|
-
RELEASE = false
|
17
|
-
end
|
9
|
+
# none
|
18
10
|
end
|
19
11
|
end
|
@@ -1,19 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../abstract_version'
|
4
|
-
|
5
3
|
# :nodoc:
|
6
4
|
module Zakuro
|
7
5
|
#
|
8
6
|
# Kansei 寛政暦
|
9
7
|
#
|
10
8
|
module Kansei
|
11
|
-
#
|
12
|
-
# Gateway アクセサメソッド群
|
13
|
-
#
|
14
|
-
class Gateway < AbstractVersion
|
15
|
-
# @return [False] リリースなし
|
16
|
-
RELEASE = false
|
17
|
-
end
|
9
|
+
# none
|
18
10
|
end
|
19
11
|
end
|
@@ -35,8 +35,6 @@ module Zakuro
|
|
35
35
|
# @note ANOMALISTIC_MONTH (1近点月)の半分に相当する
|
36
36
|
HALF_ANOMALISTIC_MONTH = \
|
37
37
|
Cycle::LunarRemainder.new(day: 13, minute: 6529, second: 9.5)
|
38
|
-
# @return [Cycle::LunarRemainder] 入暦上限
|
39
|
-
LIMIT = Cycle::LunarRemainder.new(day: 14, minute: 6529, second: 0)
|
40
38
|
#
|
41
39
|
# @note 章月 248057 = 29-4457
|
42
40
|
#
|
@@ -11,12 +11,7 @@ module Zakuro
|
|
11
11
|
# :nodoc:
|
12
12
|
module Cycle
|
13
13
|
#
|
14
|
-
# Remainder
|
15
|
-
#
|
16
|
-
# * 「15日1835分5秒」のような形式で表される
|
17
|
-
# * 分は8400で一日に繰り上げる
|
18
|
-
# * 秒は基本的に1/8分で、8秒で1分に繰り上げる。ただし、月補正値は1分に100秒とするなど基数の変更がありえる
|
19
|
-
# * 十干十二支(60日)を上限とした「日時分秒」の情報で、日付(date)/時刻(time)と部分的に重なる概念
|
14
|
+
# Remainder 時刻情報(大余小余)
|
20
15
|
#
|
21
16
|
class Remainder < Calculation::Cycle::AbstractRemainder
|
22
17
|
# @return [Integer] 分(1分=8秒)
|
@@ -34,6 +29,19 @@ module Zakuro
|
|
34
29
|
super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
|
35
30
|
day: day, minute: minute, second: second, total: total)
|
36
31
|
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# 特定の文字フォーマットにして出力する
|
35
|
+
#
|
36
|
+
# @param [String] form フォーマット(大余、小余、秒それぞれを%dで指定する)
|
37
|
+
#
|
38
|
+
# @return [String] フォーマットした結果
|
39
|
+
#
|
40
|
+
def format(form: '%d-%d')
|
41
|
+
return '' if invalid?
|
42
|
+
|
43
|
+
super(form, @day, @minute, @second)
|
44
|
+
end
|
37
45
|
end
|
38
46
|
|
39
47
|
#
|
@@ -55,6 +63,19 @@ module Zakuro
|
|
55
63
|
super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
|
56
64
|
day: day, minute: minute, second: second, total: total)
|
57
65
|
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# 特定の文字フォーマットにして出力する
|
69
|
+
#
|
70
|
+
# @param [String] form フォーマット(大余、小余、秒それぞれを%dで指定する)
|
71
|
+
#
|
72
|
+
# @return [String] フォーマットした結果
|
73
|
+
#
|
74
|
+
def format(form: '%d-%d')
|
75
|
+
return '' if invalid?
|
76
|
+
|
77
|
+
super(form, @day, @minute, @second)
|
78
|
+
end
|
58
79
|
end
|
59
80
|
end
|
60
81
|
end
|
@@ -1,40 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'date'
|
4
|
-
require_relative '../../era/western'
|
5
|
-
require_relative '../abstract_version'
|
6
|
-
require_relative '../context'
|
7
|
-
require_relative '../../calculation/summary/single'
|
8
|
-
|
9
3
|
# :nodoc:
|
10
4
|
module Zakuro
|
11
5
|
#
|
12
6
|
# Senmyou 宣明暦
|
13
7
|
#
|
14
8
|
module Senmyou
|
15
|
-
#
|
16
|
-
# Gateway アクセサメソッド群
|
17
|
-
#
|
18
|
-
class Gateway < AbstractVersion
|
19
|
-
# @return [True] リリースあり
|
20
|
-
RELEASE = true
|
21
|
-
|
22
|
-
# @return [String] 暦クラス名
|
23
|
-
VERSION_NAME = 'Senmyou'
|
24
|
-
|
25
|
-
#
|
26
|
-
# 西暦日から和暦日に変換する
|
27
|
-
#
|
28
|
-
# @param [Date] western_date 西暦日
|
29
|
-
#
|
30
|
-
# @return [Result::Single] 和暦日
|
31
|
-
#
|
32
|
-
def self.to_japan_date(western_date:)
|
33
|
-
date = Western::Calendar.create(date: western_date)
|
34
|
-
|
35
|
-
context = Context.new(version_name: VERSION_NAME)
|
36
|
-
Calculation::Summary::Single.get(context: context, date: date)
|
37
|
-
end
|
38
|
-
end
|
9
|
+
# none
|
39
10
|
end
|
40
11
|
end
|
@@ -18,8 +18,6 @@ module Zakuro
|
|
18
18
|
class Location < Calculation::Lunar::AbstractLocation
|
19
19
|
# @return [Cycle::LunarRemainder] 暦中日(1近点月の半分)
|
20
20
|
HALF_ANOMALISTIC_MONTH = Const::Remainder::Lunar::HALF_ANOMALISTIC_MONTH
|
21
|
-
# @return [Cycle::LunarRemainder] 入暦上限
|
22
|
-
LIMIT = Const::Remainder::Lunar::LIMIT
|
23
21
|
# @return [Cycle::LunarRemainder] 弦
|
24
22
|
QUARTER = Const::Remainder::Lunar::QUARTER
|
25
23
|
|
@@ -44,8 +42,7 @@ module Zakuro
|
|
44
42
|
#
|
45
43
|
def run
|
46
44
|
if calculated
|
47
|
-
|
48
|
-
decrease(limit: LIMIT)
|
45
|
+
decrease(limit: HALF_ANOMALISTIC_MONTH)
|
49
46
|
return
|
50
47
|
end
|
51
48
|
|
@@ -68,10 +65,7 @@ module Zakuro
|
|
68
65
|
@remainder = Localization.first_remainder(
|
69
66
|
lunar_age: remainder, western_year: western_year
|
70
67
|
)
|
71
|
-
# 初回は0始まりで計算しているので、入暦上限ではなく暦中日を用いる
|
72
68
|
decrease(limit: HALF_ANOMALISTIC_MONTH)
|
73
|
-
# 1始まりに改める
|
74
|
-
one_based
|
75
69
|
|
76
70
|
@calculated = true
|
77
71
|
end
|
@@ -84,7 +78,7 @@ module Zakuro
|
|
84
78
|
def decrease(limit:)
|
85
79
|
return if remainder < limit
|
86
80
|
|
87
|
-
remainder.sub!(
|
81
|
+
remainder.sub!(limit)
|
88
82
|
@forward = !forward
|
89
83
|
end
|
90
84
|
end
|
@@ -29,8 +29,9 @@ module Zakuro
|
|
29
29
|
def self.get(remainder:, forward:)
|
30
30
|
valid?(remainder: remainder)
|
31
31
|
|
32
|
-
day =
|
33
|
-
|
32
|
+
day, minute = Calculation::Lunar::ChoukeiValue.remainder_without_second(
|
33
|
+
remainder: remainder
|
34
|
+
)
|
34
35
|
|
35
36
|
# 引き当て
|
36
37
|
row = Adjustment.specify(forward: forward, day: day, minute: minute)
|
@@ -55,7 +55,7 @@ module Zakuro
|
|
55
55
|
# 二十四節気(冬至)
|
56
56
|
solar_term = Cycle::SolarTerm.new(index: 0, remainder: winter_solstice)
|
57
57
|
|
58
|
-
first_solar_term_index = Average.
|
58
|
+
first_solar_term_index = Average.calc_first_solar_term_index(western_year: western_year)
|
59
59
|
|
60
60
|
# 対象の二十四節気まで戻す
|
61
61
|
solar_term.prev_by_index(first_solar_term_index)
|
@@ -77,7 +77,7 @@ module Zakuro
|
|
77
77
|
#
|
78
78
|
# @return [Integer] 二十四節気番号
|
79
79
|
#
|
80
|
-
def self.
|
80
|
+
def self.calc_first_solar_term_index(western_year:)
|
81
81
|
# 天正閏余
|
82
82
|
lunar_age = Origin::LunarAge.get(western_year: western_year)
|
83
83
|
|
@@ -87,7 +87,7 @@ module Zakuro
|
|
87
87
|
solar_term_index = solar_location.index
|
88
88
|
|
89
89
|
# 入定気の一つ後の二十四節気まで戻す(ただし11月経朔が二十四節気上にある場合は戻さない)
|
90
|
-
solar_term_index += 1 unless solar_location.remainder
|
90
|
+
solar_term_index += 1 unless solar_location.remainder.day.zero?
|
91
91
|
|
92
92
|
solar_term_index
|
93
93
|
end
|
@@ -1,19 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../abstract_version'
|
4
|
-
|
5
3
|
# :nodoc:
|
6
4
|
module Zakuro
|
7
5
|
#
|
8
6
|
# Tenpou 天保暦
|
9
7
|
#
|
10
8
|
module Tenpou
|
11
|
-
#
|
12
|
-
# Gateway アクセサメソッド群
|
13
|
-
#
|
14
|
-
class Gateway < AbstractVersion
|
15
|
-
# @return [False] リリースなし
|
16
|
-
RELEASE = false
|
17
|
-
end
|
9
|
+
# none
|
18
10
|
end
|
19
11
|
end
|
@@ -1,9 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './genka/cycle/remainder'
|
4
|
+
require_relative './genka/cycle/solar_term'
|
5
|
+
require_relative './genka/range/annual_range'
|
6
|
+
|
3
7
|
require_relative './gihou/cycle/remainder'
|
4
8
|
require_relative './gihou/cycle/solar_term'
|
5
9
|
require_relative './gihou/range/annual_range'
|
6
10
|
|
11
|
+
require_relative './daien/cycle/remainder'
|
12
|
+
require_relative './daien/cycle/solar_term'
|
13
|
+
require_relative './daien/range/annual_range'
|
14
|
+
|
7
15
|
require_relative './senmyou/cycle/remainder'
|
8
16
|
require_relative './senmyou/cycle/solar_term'
|
9
17
|
require_relative './senmyou/range/annual_range'
|
data/zakuro.gemspec
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'lib/zakuro/version'
|
4
|
-
|
5
3
|
Gem::Specification.new do |spec|
|
6
4
|
spec.name = 'zakuro'
|
7
|
-
spec.version =
|
5
|
+
spec.version = File.read(File.expand_path('./VERSION', __dir__)).strip
|
8
6
|
spec.authors = ['pldb']
|
9
7
|
spec.email = ['pldb.github@gmail.com']
|
10
8
|
|