zakuro 0.1.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zakuro/calculation/base/multi_gengou.rb +101 -0
- data/lib/zakuro/calculation/base/multi_gengou_roller.rb +218 -0
- data/lib/zakuro/calculation/base/year.rb +107 -0
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +484 -0
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +173 -0
- data/lib/zakuro/calculation/cycle/zodiac.rb +106 -0
- data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +169 -0
- data/lib/zakuro/calculation/monthly/first_day.rb +45 -0
- data/lib/zakuro/calculation/monthly/initialized_month.rb +125 -0
- data/lib/zakuro/calculation/monthly/month.rb +187 -0
- data/lib/zakuro/calculation/monthly/month_label.rb +88 -0
- data/lib/zakuro/calculation/monthly/operated_month.rb +209 -0
- data/lib/zakuro/calculation/range/full_range.rb +210 -0
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +105 -0
- data/lib/zakuro/calculation/range/operated_range.rb +144 -0
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +201 -0
- data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +82 -0
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +146 -0
- data/lib/zakuro/calculation/specifier/single_day.rb +109 -0
- 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/summary/single.rb +129 -0
- data/lib/zakuro/calculation/type/old_float.rb +69 -0
- data/lib/zakuro/era/japan/reki.rb +1 -1
- data/lib/zakuro/merchant.rb +2 -2
- data/lib/zakuro/output/error.rb +7 -6
- data/lib/zakuro/output/logger.rb +50 -49
- data/lib/zakuro/output/response.rb +145 -144
- data/lib/zakuro/tools/typeof.rb +2 -2
- data/lib/zakuro/version.rb +1 -1
- data/lib/zakuro/version/abstract_version.rb +1 -1
- data/lib/zakuro/version/context.rb +23 -0
- 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 +59 -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/gihou/const/number.rb +55 -0
- data/lib/zakuro/version/gihou/const/remainder.rb +54 -0
- data/lib/zakuro/version/gihou/cycle/remainder.rb +56 -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 +51 -0
- data/lib/zakuro/version/senmyou/const/remainder.rb +47 -0
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +56 -0
- data/lib/zakuro/version/senmyou/cycle/solar_term.rb +34 -0
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +80 -195
- data/lib/zakuro/version/senmyou/range/annual_range.rb +25 -145
- data/lib/zakuro/version/senmyou/senmyou.rb +10 -4
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +237 -0
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +44 -0
- data/lib/zakuro/version/senmyou/stella/lunar/location.rb +87 -0
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +67 -0
- data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +34 -0
- data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +62 -0
- data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +55 -0
- data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +93 -0
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +97 -0
- data/lib/zakuro/version/senmyou/stella/solar/interval.rb +103 -0
- data/lib/zakuro/version/senmyou/stella/solar/location.rb +61 -0
- data/lib/zakuro/version/senmyou/stella/solar/value.rb +39 -0
- data/lib/zakuro/version/version_class_resolver.rb +70 -0
- data/lib/zakuro/version_factory.rb +3 -3
- metadata +83 -28
- data/lib/zakuro/cycle/abstract_remainder.rb +0 -456
- data/lib/zakuro/cycle/zodiac.rb +0 -103
- data/lib/zakuro/version/senmyou/base/era.rb +0 -83
- data/lib/zakuro/version/senmyou/base/multi_gengou.rb +0 -98
- data/lib/zakuro/version/senmyou/base/multi_gengou_roller.rb +0 -217
- data/lib/zakuro/version/senmyou/base/remainder.rb +0 -60
- data/lib/zakuro/version/senmyou/base/solar_term.rb +0 -148
- data/lib/zakuro/version/senmyou/base/year.rb +0 -104
- data/lib/zakuro/version/senmyou/monthly/first_day.rb +0 -44
- data/lib/zakuro/version/senmyou/monthly/initialized_month.rb +0 -119
- data/lib/zakuro/version/senmyou/monthly/month.rb +0 -181
- data/lib/zakuro/version/senmyou/monthly/month_label.rb +0 -87
- data/lib/zakuro/version/senmyou/monthly/operated_month.rb +0 -196
- data/lib/zakuro/version/senmyou/range/full_range.rb +0 -194
- data/lib/zakuro/version/senmyou/range/operated_range.rb +0 -126
- data/lib/zakuro/version/senmyou/range/operated_solar_terms.rb +0 -181
- data/lib/zakuro/version/senmyou/range/western_date_allocation.rb +0 -68
- data/lib/zakuro/version/senmyou/range/year_boundary.rb +0 -138
- data/lib/zakuro/version/senmyou/specifier/single_day_specifier.rb +0 -102
- data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +0 -332
- data/lib/zakuro/version/senmyou/stella/solar_average.rb +0 -169
- data/lib/zakuro/version/senmyou/stella/solar_location.rb +0 -213
- data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +0 -213
- data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +0 -106
- data/lib/zakuro/version/senmyou/summary/single.rb +0 -125
- data/lib/zakuro/version/taien/taien.rb +0 -19
@@ -1,106 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../../output/logger'
|
4
|
-
|
5
|
-
# :nodoc:
|
6
|
-
module Zakuro
|
7
|
-
# :nodoc:
|
8
|
-
module Senmyou
|
9
|
-
# :reek:TooManyConstants
|
10
|
-
|
11
|
-
#
|
12
|
-
# WinterSolstice 冬至
|
13
|
-
#
|
14
|
-
module WinterSolstice
|
15
|
-
# @return [Integer] 統法(1日=8400分)
|
16
|
-
DAY = 8400
|
17
|
-
# @return [Integer] 朔望月
|
18
|
-
SYNODIC_MONTH = 248_057
|
19
|
-
# @return [Integer] 一年
|
20
|
-
YEAR = 3_068_055
|
21
|
-
# @return [Integer] 通余: (YEAR - DAY * 12 * 30) = 44055
|
22
|
-
REMAINDER_ALL_YEAR = 44_055
|
23
|
-
# @return [Integer] 旬周(60日) 8400 * 60
|
24
|
-
SIXTY_DAYS = 504_000
|
25
|
-
# @return [Integer] 積年(甲子夜半朔旦冬至〜暦の開始前)
|
26
|
-
TOTAL_YEAR = 7_070_138
|
27
|
-
# @return [Integer] 暦の開始年(長慶2年)
|
28
|
-
BEGIN_YEAR = 822
|
29
|
-
|
30
|
-
# @return [Logger] ロガー
|
31
|
-
LOGGER = Logger.new(location: 'winter_solstice')
|
32
|
-
|
33
|
-
# :reek:TooManyStatements { max_statements: 6 }
|
34
|
-
|
35
|
-
#
|
36
|
-
# 対象年の前年の冬至を求める
|
37
|
-
#
|
38
|
-
# @param [Integer] western_year 西暦年
|
39
|
-
#
|
40
|
-
# @return [Remainder] 前年の冬至
|
41
|
-
#
|
42
|
-
def self.calc(western_year:)
|
43
|
-
# 積年の開始から対象年までの年数
|
44
|
-
total = TOTAL_YEAR + western_year - BEGIN_YEAR
|
45
|
-
remainder_year = total % SIXTY_DAYS
|
46
|
-
|
47
|
-
LOGGER.debug("[a01]:#{remainder_year}")
|
48
|
-
|
49
|
-
# 通余を使う
|
50
|
-
winter_solstice_minute = (remainder_year * REMAINDER_ALL_YEAR) % SIXTY_DAYS
|
51
|
-
|
52
|
-
LOGGER.debug("[a02]:#{winter_solstice_minute}")
|
53
|
-
|
54
|
-
Remainder.new(total: winter_solstice_minute)
|
55
|
-
end
|
56
|
-
|
57
|
-
# :reek:TooManyStatements { max_statements: 7 }
|
58
|
-
|
59
|
-
#
|
60
|
-
# 対象年の天正閏余(冬至より前にある11月経朔との差 = 月齢)を算出する
|
61
|
-
# 太陽と月の運動による補正値を算出し、その補正結果を返す
|
62
|
-
#
|
63
|
-
# @param [Integer] western_year 西暦年
|
64
|
-
#
|
65
|
-
# @return [Remainder] 天正閏余
|
66
|
-
#
|
67
|
-
def self.calc_moon_age(western_year:)
|
68
|
-
# 積年の開始から対象年までの年数
|
69
|
-
total = TOTAL_YEAR + western_year - BEGIN_YEAR
|
70
|
-
|
71
|
-
# 12朔望月に対する1年の余り(単位:分)
|
72
|
-
remainder_minute = YEAR - (SYNODIC_MONTH * 12)
|
73
|
-
|
74
|
-
# 朔望月に含まれなかった余り(単位:年)
|
75
|
-
remainder_year = total % SYNODIC_MONTH
|
76
|
-
|
77
|
-
LOGGER.debug("[b01]: #{remainder_year}")
|
78
|
-
|
79
|
-
# 天正閏余
|
80
|
-
winter_solstice_age = remainder_minute * remainder_year % SYNODIC_MONTH
|
81
|
-
|
82
|
-
LOGGER.debug("[b02]: #{winter_solstice_age}")
|
83
|
-
|
84
|
-
# 大余・小余に変換する
|
85
|
-
Remainder.new(total: winter_solstice_age)
|
86
|
-
end
|
87
|
-
|
88
|
-
#
|
89
|
-
# 11月経朔(冬至が含まれる月の1日)を求める
|
90
|
-
#
|
91
|
-
# @param [Integer] western_year 西暦年
|
92
|
-
#
|
93
|
-
# @return [Remainder] 11月経朔
|
94
|
-
#
|
95
|
-
def self.calc_averaged_last_november_1st(western_year:)
|
96
|
-
# 冬至
|
97
|
-
winter_solstice = calc(western_year: western_year)
|
98
|
-
# 天正閏余
|
99
|
-
winter_solstice_age = calc_moon_age(western_year: western_year)
|
100
|
-
|
101
|
-
# 11月経朔
|
102
|
-
winter_solstice.sub(winter_solstice_age)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require File.expand_path('../../../../../' \
|
4
|
-
'lib/zakuro/version/senmyou/specifier/single_day_specifier',
|
5
|
-
__dir__)
|
6
|
-
|
7
|
-
require File.expand_path('../../../../../' \
|
8
|
-
'lib/zakuro/version/senmyou/range/full_range',
|
9
|
-
__dir__)
|
10
|
-
|
11
|
-
require File.expand_path('../../../../../' \
|
12
|
-
'lib/zakuro/version/senmyou/range/operated_range',
|
13
|
-
__dir__)
|
14
|
-
|
15
|
-
# :nodoc:
|
16
|
-
module Zakuro
|
17
|
-
# :nodoc:
|
18
|
-
module Senmyou
|
19
|
-
#
|
20
|
-
# Single 一日
|
21
|
-
#
|
22
|
-
module Single
|
23
|
-
#
|
24
|
-
# 生成する
|
25
|
-
#
|
26
|
-
# @param [Western::Calendar] date 西暦日
|
27
|
-
#
|
28
|
-
# @return [Result::Single] 一日検索結果(和暦日)
|
29
|
-
#
|
30
|
-
def self.get(date: Western::Calendar.new)
|
31
|
-
full_range = FullRange.new(start_date: date)
|
32
|
-
years = full_range.get
|
33
|
-
|
34
|
-
calc_date = SingleDaySpecifier.get(years: years, date: date)
|
35
|
-
|
36
|
-
operated_range = OperatedRange.new(years: years)
|
37
|
-
|
38
|
-
Result::Single.new(
|
39
|
-
data: SingleDaySpecifier.get(years: operated_range.get, date: date),
|
40
|
-
operation: create_operation(calc_date: calc_date)
|
41
|
-
)
|
42
|
-
end
|
43
|
-
|
44
|
-
#
|
45
|
-
# 運用情報を生成する
|
46
|
-
#
|
47
|
-
# @param [Result::Data::SingleDay] calc_date 和暦日(計算値)
|
48
|
-
#
|
49
|
-
# @return [Result::Operation::Bundle] 運用情報
|
50
|
-
#
|
51
|
-
def self.create_operation(calc_date: Result::Data::SingleDay.new)
|
52
|
-
first_day = calc_date.month.first_day.western_date
|
53
|
-
operation_history = Operation.specify_history(western_date: first_day)
|
54
|
-
|
55
|
-
operation_month = create_operation_month(operation_history: operation_history)
|
56
|
-
|
57
|
-
Result::Operation::Bundle.new(
|
58
|
-
operated: !operation_history.invalid?, month: operation_month, original: calc_date
|
59
|
-
)
|
60
|
-
end
|
61
|
-
private_class_method :create_operation
|
62
|
-
|
63
|
-
#
|
64
|
-
# 月履歴集約情報を生成する
|
65
|
-
#
|
66
|
-
# @param [Operation::MonthHistory] operation_history 変更履歴(月)
|
67
|
-
#
|
68
|
-
# @return [Result::Operation::Month::Bundle] 月履歴集約情報
|
69
|
-
#
|
70
|
-
def self.create_operation_month(operation_history: Operation::MonthHistory.new)
|
71
|
-
return Result::Operation::Month::Bundle.new if operation_history.invalid?
|
72
|
-
|
73
|
-
parent_operation_history = Operation.specify_history_by_id(id: operation_history.parent_id)
|
74
|
-
|
75
|
-
Result::Operation::Month::Bundle.new(
|
76
|
-
current: create_operation_month_history(operation_history: operation_history),
|
77
|
-
parent: create_operation_month_history(operation_history: parent_operation_history)
|
78
|
-
)
|
79
|
-
end
|
80
|
-
private_class_method :create_operation_month
|
81
|
-
|
82
|
-
#
|
83
|
-
# 月別履歴情報を生成する
|
84
|
-
#
|
85
|
-
# @param [Operation::MonthHistory] operation_history 変更履歴(月)
|
86
|
-
#
|
87
|
-
# @return [Result::Operation::Month::History] 月別履歴情報
|
88
|
-
#
|
89
|
-
def self.create_operation_month_history(operation_history: Operation::MonthHistory.new)
|
90
|
-
return Result::Operation::Month::History.new if operation_history.invalid?
|
91
|
-
|
92
|
-
annotations = create_annnotations(operation_history: operation_history)
|
93
|
-
|
94
|
-
reference = operation_history.reference
|
95
|
-
Result::Operation::Month::History.new(
|
96
|
-
id: operation_history.id, western_date: operation_history.western_date.format,
|
97
|
-
page: reference.page, number: reference.number, annotations: annotations
|
98
|
-
)
|
99
|
-
end
|
100
|
-
private_class_method :create_operation_month_history
|
101
|
-
|
102
|
-
#
|
103
|
-
# 注釈情報を生成する
|
104
|
-
#
|
105
|
-
# @param [Operation::MonthHistory] operation_history 変更履歴(月)
|
106
|
-
#
|
107
|
-
# @return [Array<Result::Operation::Month::Annotation>] 注釈
|
108
|
-
#
|
109
|
-
def self.create_annnotations(operation_history: Operation::MonthHistory.new)
|
110
|
-
annotations = []
|
111
|
-
operation_history.annotations.each do |annotation|
|
112
|
-
annotations.push(
|
113
|
-
Result::Operation::Month::Annotation.new(
|
114
|
-
description: annotation.description,
|
115
|
-
note: annotation.note
|
116
|
-
)
|
117
|
-
)
|
118
|
-
end
|
119
|
-
|
120
|
-
annotations
|
121
|
-
end
|
122
|
-
private_class_method :create_annnotations
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../abstract_version'
|
4
|
-
|
5
|
-
# :nodoc:
|
6
|
-
module Zakuro
|
7
|
-
#
|
8
|
-
# Taien 大衍暦
|
9
|
-
#
|
10
|
-
module Taien
|
11
|
-
#
|
12
|
-
# Gateway アクセサメソッド群
|
13
|
-
#
|
14
|
-
class Gateway < AbstractVersion
|
15
|
-
# @return [False] リリースなし
|
16
|
-
RELEASE = false
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|