zakuro 0.9.0 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +50 -178
- data/VERSION +1 -1
- data/doc/condition.md +38 -0
- data/doc/dropped_date.md +41 -0
- data/doc/expection.md +119 -0
- data/doc/operation/csv/month.csv +4 -4
- data/doc/operation/operation.xlsx +0 -0
- data/doc/usage.md +120 -0
- data/doc/vanished_date.md +86 -0
- data/doc/version/daien.md +163 -0
- data/doc/version/genka.md +116 -0
- data/doc/version/gihou.md +172 -0
- data/doc/version/section/common_post_process.md +60 -0
- data/doc/version/section/common_pre_process.md +185 -0
- data/doc/version/section/const.md +45 -0
- data/doc/version/section/decimal.md +101 -0
- data/doc/version/section/lunisolar_calendar.md +55 -0
- data/doc/version/section/senmyou_november_1st.md +41 -0
- data/{lib/zakuro/version/senmyou/README.md → doc/version/senmyou.md} +15 -168
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +58 -0
- data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +2 -2
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +5 -5
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +1 -1
- data/lib/zakuro/calculation/monthly/first_day.rb +9 -1
- data/lib/zakuro/calculation/monthly/operated_month.rb +18 -1
- data/lib/zakuro/calculation/option/vanished_date/abstract_parameter.rb +40 -0
- data/lib/zakuro/calculation/option/vanished_date/location.rb +84 -0
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +5 -3
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +1 -0
- data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +6 -2
- data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +14 -0
- data/lib/zakuro/calculation/summary/internal/option.rb +71 -9
- data/lib/zakuro/context/option.rb +17 -0
- data/lib/zakuro/context/version_class_resolver.rb +17 -1
- data/lib/zakuro/era/japan/calendar.rb +2 -2
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +2 -2
- data/lib/zakuro/era/western/calendar.rb +5 -11
- data/lib/zakuro/era/western/date_text.rb +40 -0
- data/lib/zakuro/gateway/locale/date.rb +2 -2
- data/lib/zakuro/operation/month/validator.rb +7 -1
- data/lib/zakuro/operation/yaml/month.yaml +14 -14
- data/lib/zakuro/result/data/option/vanished_date/calculation.rb +45 -0
- data/lib/zakuro/result/data/option/vanished_date/option.rb +47 -0
- data/lib/zakuro/result/data/single_day.rb +2 -0
- data/lib/zakuro/version/daien/const/number.rb +2 -0
- data/lib/zakuro/version/daien/const/remainder.rb +7 -2
- data/lib/zakuro/version/daien/cycle/remainder.rb +38 -20
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +2 -4
- data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +5 -3
- data/lib/zakuro/version/daien/option/vanished_date/parameter.rb +33 -0
- data/lib/zakuro/version/daien/stella/lunar/location.rb +5 -8
- data/lib/zakuro/version/genka/cycle/remainder.rb +6 -2
- data/lib/zakuro/version/genka/monthly/lunar_phase.rb +14 -3
- data/lib/zakuro/version/genka/option/vanished_date/parameter.rb +31 -0
- data/lib/zakuro/version/gihou/const/remainder.rb +1 -5
- data/lib/zakuro/version/gihou/cycle/remainder.rb +0 -26
- data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +2 -4
- data/lib/zakuro/version/gihou/option/vanished_date/parameter.rb +31 -0
- data/lib/zakuro/version/gihou/stella/lunar/location.rb +5 -8
- data/lib/zakuro/version/senmyou/const/number.rb +3 -1
- data/lib/zakuro/version/senmyou/const/remainder.rb +4 -2
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +17 -34
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +5 -5
- data/lib/zakuro/version/senmyou/option/vanished_date/parameter.rb +33 -0
- data/lib/zakuro/version/senmyou/stella/lunar/location.rb +6 -8
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +9 -0
- metadata +25 -3
@@ -3,8 +3,10 @@
|
|
3
3
|
require_relative '../../../context/option'
|
4
4
|
require_relative '../../../result/data/option/dropped_date/option'
|
5
5
|
require_relative '../../../result/data/solar_term'
|
6
|
+
require_relative '../../../result/data/option/vanished_date/option'
|
6
7
|
|
7
8
|
require_relative '../../option/dropped_date/location'
|
9
|
+
require_relative '../../option/vanished_date/location'
|
8
10
|
|
9
11
|
# :nodoc:
|
10
12
|
module Zakuro
|
@@ -26,6 +28,8 @@ module Zakuro
|
|
26
28
|
# @return [Hash<String, Result::Data::Option::AbstractOption>] オプション結果
|
27
29
|
#
|
28
30
|
def create(month:, day:)
|
31
|
+
# TODO: refactor
|
32
|
+
|
29
33
|
options = {}
|
30
34
|
context = month.context
|
31
35
|
|
@@ -38,6 +42,15 @@ module Zakuro
|
|
38
42
|
options[Context::Option::DROPPED_DATE_KEY] = option
|
39
43
|
end
|
40
44
|
|
45
|
+
if context.option.vanished_date?
|
46
|
+
remainder = day.remainder
|
47
|
+
average_remainder = month.first_day.average_remainder
|
48
|
+
option = vanished_date(
|
49
|
+
context: context, remainder: remainder, average_remainder: average_remainder
|
50
|
+
)
|
51
|
+
options[Context::Option::VANISHED_DATE_KEY] = option
|
52
|
+
end
|
53
|
+
|
41
54
|
options
|
42
55
|
end
|
43
56
|
|
@@ -53,10 +66,7 @@ module Zakuro
|
|
53
66
|
# @return [Result::Data::Option::DroppedDate::Option] 没日
|
54
67
|
#
|
55
68
|
def dropped_date(context:, remainder:, solar_terms:)
|
56
|
-
option = Result::Data::Option::DroppedDate::Option.new
|
57
|
-
matched: false,
|
58
|
-
calculation: Result::Data::Option::DroppedDate::Calculation.new
|
59
|
-
)
|
69
|
+
option = Result::Data::Option::DroppedDate::Option.new
|
60
70
|
|
61
71
|
return option if remainder.invalid?
|
62
72
|
|
@@ -68,23 +78,24 @@ module Zakuro
|
|
68
78
|
|
69
79
|
dropped_date = location.get
|
70
80
|
|
71
|
-
|
72
|
-
|
73
|
-
|
81
|
+
dropped_date_option(
|
82
|
+
matched: remainder.day == dropped_date.day, location: location
|
83
|
+
)
|
74
84
|
end
|
75
85
|
|
76
86
|
#
|
77
87
|
# 没日オプション値を生成する
|
78
88
|
#
|
89
|
+
# @param [True, False] matched 没日有無
|
79
90
|
# @param [Calculation::Option::DroppedDate::Location] location 没日位置
|
80
91
|
#
|
81
92
|
# @return [Result::Data::Option::DroppedDate::Option] 没日オプション値
|
82
93
|
#
|
83
|
-
def dropped_date_option(location:)
|
94
|
+
def dropped_date_option(matched:, location:)
|
84
95
|
dropped_date = location.get
|
85
96
|
solar_term = location.solar_term
|
86
97
|
Result::Data::Option::DroppedDate::Option.new(
|
87
|
-
matched:
|
98
|
+
matched: matched,
|
88
99
|
calculation: Result::Data::Option::DroppedDate::Calculation.new(
|
89
100
|
remainder: dropped_date.format,
|
90
101
|
solar_term: Result::Data::SolarTerm.new(
|
@@ -94,6 +105,57 @@ module Zakuro
|
|
94
105
|
)
|
95
106
|
)
|
96
107
|
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# 滅日を求める
|
111
|
+
#
|
112
|
+
# @param [Context::Context] context 暦コンテキスト
|
113
|
+
# @param [Cycle::AbstractRemainder] remainder 当日和暦日
|
114
|
+
# @param [Cycle::AbstractRemainder] average_remainder 経朔
|
115
|
+
#
|
116
|
+
# @return [Result::Data::Option::VanishedDate::Option] 滅日オプション値
|
117
|
+
#
|
118
|
+
def vanished_date(context:, remainder:, average_remainder:)
|
119
|
+
return Result::Data::Option::VanishedDate::Option.new if average_remainder.invalid?
|
120
|
+
|
121
|
+
location = Calculation::Option::VanishedDate::Location.new(
|
122
|
+
context: context, average_remainder: average_remainder
|
123
|
+
)
|
124
|
+
|
125
|
+
unless location.exist?
|
126
|
+
# 結果確認のため経朔だけは設定する
|
127
|
+
return Result::Data::Option::VanishedDate::Option.new(
|
128
|
+
calculation: Result::Data::Option::VanishedDate::Calculation.new(
|
129
|
+
average_remainder: average_remainder
|
130
|
+
)
|
131
|
+
)
|
132
|
+
end
|
133
|
+
|
134
|
+
vanished_date = location.get
|
135
|
+
|
136
|
+
vanished_date_option(
|
137
|
+
matched: remainder.day == vanished_date.day, location: location
|
138
|
+
)
|
139
|
+
end
|
140
|
+
|
141
|
+
#
|
142
|
+
# 滅日オプション値を生成する
|
143
|
+
#
|
144
|
+
# @param [True, False] matched 滅日有無
|
145
|
+
# @param [Calculation::Option::VanishedDate::Location] location 滅日位置
|
146
|
+
#
|
147
|
+
# @return [Result::Data::Option::VanishedDate::Option] 滅日オプション値
|
148
|
+
#
|
149
|
+
def vanished_date_option(matched:, location:)
|
150
|
+
vanished_date = location.get
|
151
|
+
Result::Data::Option::VanishedDate::Option.new(
|
152
|
+
matched: matched,
|
153
|
+
calculation: Result::Data::Option::VanishedDate::Calculation.new(
|
154
|
+
remainder: vanished_date.format,
|
155
|
+
average_remainder: location.average_remainder
|
156
|
+
)
|
157
|
+
)
|
158
|
+
end
|
97
159
|
end
|
98
160
|
end
|
99
161
|
end
|
@@ -16,6 +16,9 @@ module Zakuro
|
|
16
16
|
# @return [String] 没日オプションキー名
|
17
17
|
DROPPED_DATE_KEY = 'dropped_date'
|
18
18
|
|
19
|
+
# @return [String] 滅日オプションキー名
|
20
|
+
VANISHED_DATE_KEY = 'vanished_date'
|
21
|
+
|
19
22
|
# @return [Hash<String, Object>] オプション値
|
20
23
|
attr_reader :hash
|
21
24
|
# @return [String] デフォルト暦名
|
@@ -82,6 +85,20 @@ module Zakuro
|
|
82
85
|
false
|
83
86
|
end
|
84
87
|
|
88
|
+
#
|
89
|
+
# 滅日か
|
90
|
+
#
|
91
|
+
# @return [True] 滅日あり
|
92
|
+
# @return [False] 滅日なし
|
93
|
+
#
|
94
|
+
def vanished_date?
|
95
|
+
value = @hash[VANISHED_DATE_KEY]
|
96
|
+
|
97
|
+
return true if value.is_a?(TrueClass)
|
98
|
+
|
99
|
+
false
|
100
|
+
end
|
101
|
+
|
85
102
|
class << self
|
86
103
|
#
|
87
104
|
# 暦名を返す
|
@@ -4,21 +4,25 @@ require_relative '../version/genka/cycle/remainder'
|
|
4
4
|
require_relative '../version/genka/cycle/solar_term'
|
5
5
|
require_relative '../version/genka/range/annual_range'
|
6
6
|
require_relative '../version/genka/option/dropped_date/parameter'
|
7
|
+
require_relative '../version/genka/option/vanished_date/parameter'
|
7
8
|
|
8
9
|
require_relative '../version/gihou/cycle/remainder'
|
9
10
|
require_relative '../version/gihou/cycle/solar_term'
|
10
11
|
require_relative '../version/gihou/range/annual_range'
|
11
12
|
require_relative '../version/gihou/option/dropped_date/parameter'
|
13
|
+
require_relative '../version/gihou/option/vanished_date/parameter'
|
12
14
|
|
13
15
|
require_relative '../version/daien/cycle/remainder'
|
14
16
|
require_relative '../version/daien/cycle/solar_term'
|
15
17
|
require_relative '../version/daien/range/annual_range'
|
16
18
|
require_relative '../version/daien/option/dropped_date/parameter'
|
19
|
+
require_relative '../version/daien/option/vanished_date/parameter'
|
17
20
|
|
18
21
|
require_relative '../version/senmyou/cycle/remainder'
|
19
22
|
require_relative '../version/senmyou/cycle/solar_term'
|
20
23
|
require_relative '../version/senmyou/range/annual_range'
|
21
24
|
require_relative '../version/senmyou/option/dropped_date/parameter'
|
25
|
+
require_relative '../version/senmyou/option/vanished_date/parameter'
|
22
26
|
|
23
27
|
# :nodoc:
|
24
28
|
module Zakuro
|
@@ -36,7 +40,8 @@ module Zakuro
|
|
36
40
|
'remainder' => 'Zakuro::$VERSION::Cycle::Remainder',
|
37
41
|
'solar_term' => 'Zakuro::$VERSION::Cycle::SolarTerm',
|
38
42
|
'annual_range' => 'Zakuro::$VERSION::Range::AnnualRange',
|
39
|
-
'dropped_date_parameter' => 'Zakuro::$VERSION::Option::DroppedDate::Parameter'
|
43
|
+
'dropped_date_parameter' => 'Zakuro::$VERSION::Option::DroppedDate::Parameter',
|
44
|
+
'vanished_date_parameter' => 'Zakuro::$VERSION::Option::VanishedDate::Parameter'
|
40
45
|
}.freeze
|
41
46
|
|
42
47
|
#
|
@@ -86,6 +91,17 @@ module Zakuro
|
|
86
91
|
)
|
87
92
|
end
|
88
93
|
|
94
|
+
#
|
95
|
+
# 滅日引数を返す
|
96
|
+
#
|
97
|
+
# @return [Class] 没日引数クラス
|
98
|
+
#
|
99
|
+
def vanished_date_parameter
|
100
|
+
self.class.get_class(
|
101
|
+
version_name: @version_name, class_name: 'vanished_date_parameter'
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
89
105
|
class << self
|
90
106
|
#
|
91
107
|
# 該当の暦のクラスを取得する
|
@@ -98,7 +98,7 @@ module Zakuro
|
|
98
98
|
# @return [Calendar] 年月日情報(和暦)
|
99
99
|
#
|
100
100
|
def parse(regex: FORMAT, text: '')
|
101
|
-
return Calendar.new unless
|
101
|
+
return Calendar.new unless valid_date_text(regex: regex, text: text)
|
102
102
|
|
103
103
|
matched = text.match(regex)
|
104
104
|
|
@@ -120,7 +120,7 @@ module Zakuro
|
|
120
120
|
# @return [True] 正しい
|
121
121
|
# @return [True] 正しくない
|
122
122
|
#
|
123
|
-
def
|
123
|
+
def valid_date_text(regex: FORMAT, text: '')
|
124
124
|
return false unless text
|
125
125
|
|
126
126
|
matched = text.match(regex)
|
@@ -315,7 +315,7 @@ module Zakuro
|
|
315
315
|
# @return [False] 正しくない
|
316
316
|
#
|
317
317
|
def japan?
|
318
|
-
Japan::Calendar.
|
318
|
+
Japan::Calendar.valid_date_text(text: japan)
|
319
319
|
end
|
320
320
|
|
321
321
|
#
|
@@ -325,7 +325,7 @@ module Zakuro
|
|
325
325
|
# @return [False] 正しくない
|
326
326
|
#
|
327
327
|
def western?
|
328
|
-
Western::Calendar.
|
328
|
+
Western::Calendar.valid_date_text(text: western)
|
329
329
|
end
|
330
330
|
end
|
331
331
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './date_text'
|
4
|
+
|
3
5
|
require 'date'
|
4
6
|
|
5
7
|
# :nodoc:
|
@@ -402,9 +404,7 @@ module Zakuro
|
|
402
404
|
# @raise [ArgumentError] 引数エラー
|
403
405
|
#
|
404
406
|
def parse(text: '', type: Type::DEFAULT)
|
405
|
-
unless
|
406
|
-
raise ArgumentError, "invalid date string: #{text}"
|
407
|
-
end
|
407
|
+
raise ArgumentError, "invalid date string: #{text}" unless valid_date_text(text: text)
|
408
408
|
|
409
409
|
start = DATE_START.fetch(type, DATE_START[Type::DEFAULT])
|
410
410
|
date = Date.parse(text, start)
|
@@ -423,14 +423,8 @@ module Zakuro
|
|
423
423
|
# @return [True] 正しい
|
424
424
|
# @return [True] 正しくない
|
425
425
|
#
|
426
|
-
def
|
427
|
-
|
428
|
-
begin
|
429
|
-
Date.parse(text, start)
|
430
|
-
rescue ArgumentError => _e
|
431
|
-
return false
|
432
|
-
end
|
433
|
-
true
|
426
|
+
def valid_date_text(text: '')
|
427
|
+
DateText.validate(text: text)
|
434
428
|
end
|
435
429
|
end
|
436
430
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :nodoc:
|
4
|
+
module Zakuro
|
5
|
+
#
|
6
|
+
# Western 西暦
|
7
|
+
#
|
8
|
+
module Western
|
9
|
+
#
|
10
|
+
# DateText 日付文字列
|
11
|
+
#
|
12
|
+
module DateText
|
13
|
+
# @return [Regexp] ハイフン区切り
|
14
|
+
HYPHEN = /^[0-9]{1,5}-[0-9]{1,2}-[0-9]{1,2}$/.freeze
|
15
|
+
# @return [Regexp] スラッシュ区切り
|
16
|
+
SLASH = %r{^[0-9]{1,5}/[0-9]{1,2}/[0-9]{1,2}$}.freeze
|
17
|
+
|
18
|
+
#
|
19
|
+
# 有効な日付文字列か検証する
|
20
|
+
#
|
21
|
+
# * 従来は Date.parse で日付文字列を検証していた
|
22
|
+
# * [貞観4年3月20日] のような文字列でも有効扱いになっていた
|
23
|
+
# * [20] [20日] のように2桁の数字が含まれると有効な日付扱いされる
|
24
|
+
# * 特定のフォーマットのみ受け付けるように改変した
|
25
|
+
#
|
26
|
+
# @param [String] text 文字列
|
27
|
+
#
|
28
|
+
# @return [True] 有効
|
29
|
+
# @return [True] 無効
|
30
|
+
#
|
31
|
+
def self.validate(text: '')
|
32
|
+
return true if HYPHEN.match(text)
|
33
|
+
|
34
|
+
return true if SLASH.match(text)
|
35
|
+
|
36
|
+
false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -112,12 +112,12 @@ module Zakuro
|
|
112
112
|
# @param [String] text 日付文字列
|
113
113
|
#
|
114
114
|
def parse_text(text:)
|
115
|
-
if Western::Calendar.
|
115
|
+
if Western::Calendar.valid_date_text(text: text)
|
116
116
|
@western_date = Western::Calendar.parse(text: text)
|
117
117
|
return
|
118
118
|
end
|
119
119
|
|
120
|
-
return unless Japan::Calendar.
|
120
|
+
return unless Japan::Calendar.valid_date_text(text: text)
|
121
121
|
|
122
122
|
@japan_date = Japan::Calendar.parse(text: text)
|
123
123
|
end
|
@@ -136,7 +136,13 @@ module Zakuro
|
|
136
136
|
def western_date?(str: '')
|
137
137
|
return Western::Calendar.new if str == EMPTY_STRING
|
138
138
|
|
139
|
-
|
139
|
+
# 1316-11-16/1317-4-13
|
140
|
+
dates = str.split('/')
|
141
|
+
dates.each do |date|
|
142
|
+
return true if Western::Calendar.valid_date_text(text: date)
|
143
|
+
end
|
144
|
+
|
145
|
+
false
|
140
146
|
end
|
141
147
|
end
|
142
148
|
end
|
@@ -11697,11 +11697,11 @@
|
|
11697
11697
|
diffs:
|
11698
11698
|
month:
|
11699
11699
|
number:
|
11700
|
-
src:
|
11701
|
-
dest:
|
11700
|
+
src: '8'
|
11701
|
+
dest: '7'
|
11702
11702
|
leaped:
|
11703
|
-
src:
|
11704
|
-
dest:
|
11703
|
+
src: 'false'
|
11704
|
+
dest: 'true'
|
11705
11705
|
days:
|
11706
11706
|
src: 大
|
11707
11707
|
dest: 小
|
@@ -11730,11 +11730,11 @@
|
|
11730
11730
|
diffs:
|
11731
11731
|
month:
|
11732
11732
|
number:
|
11733
|
-
src:
|
11734
|
-
dest:
|
11733
|
+
src: '8'
|
11734
|
+
dest: '8'
|
11735
11735
|
leaped:
|
11736
|
-
src:
|
11737
|
-
dest:
|
11736
|
+
src: 'true'
|
11737
|
+
dest: 'false'
|
11738
11738
|
days:
|
11739
11739
|
src: 大
|
11740
11740
|
dest: 大
|
@@ -15070,10 +15070,10 @@
|
|
15070
15070
|
diffs:
|
15071
15071
|
month:
|
15072
15072
|
number:
|
15073
|
-
src: '
|
15073
|
+
src: '12'
|
15074
15074
|
dest: '11'
|
15075
15075
|
leaped:
|
15076
|
-
src: '
|
15076
|
+
src: 'false'
|
15077
15077
|
dest: 'false'
|
15078
15078
|
days:
|
15079
15079
|
src: 大
|
@@ -15102,11 +15102,11 @@
|
|
15102
15102
|
diffs:
|
15103
15103
|
month:
|
15104
15104
|
number:
|
15105
|
-
src:
|
15106
|
-
dest:
|
15105
|
+
src: '12'
|
15106
|
+
dest: '12'
|
15107
15107
|
leaped:
|
15108
|
-
src:
|
15109
|
-
dest:
|
15108
|
+
src: 'true'
|
15109
|
+
dest: 'false'
|
15110
15110
|
days:
|
15111
15111
|
src: 大
|
15112
15112
|
dest: 大
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :nodoc:
|
4
|
+
module Zakuro
|
5
|
+
#
|
6
|
+
# Result 演算結果
|
7
|
+
#
|
8
|
+
module Result
|
9
|
+
#
|
10
|
+
# データ部
|
11
|
+
#
|
12
|
+
module Data
|
13
|
+
#
|
14
|
+
# Option オプション
|
15
|
+
#
|
16
|
+
module Option
|
17
|
+
#
|
18
|
+
# VanishedDate 滅日
|
19
|
+
#
|
20
|
+
module VanishedDate
|
21
|
+
#
|
22
|
+
# Calculation 演算値
|
23
|
+
#
|
24
|
+
class Calculation
|
25
|
+
# @return [String] 大余小余(滅余)
|
26
|
+
attr_reader :remainder
|
27
|
+
# @return [String] 経朔
|
28
|
+
attr_reader :average_remainder
|
29
|
+
|
30
|
+
#
|
31
|
+
# 初期化
|
32
|
+
#
|
33
|
+
# @param [String] remainder 大余小余(滅余)
|
34
|
+
# @param [String] average_remainder 経朔
|
35
|
+
#
|
36
|
+
def initialize(remainder: '', average_remainder: '')
|
37
|
+
@remainder = remainder
|
38
|
+
@average_remainder = average_remainder
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../abstract_option'
|
4
|
+
|
5
|
+
require_relative './calculation'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
#
|
10
|
+
# Result 演算結果
|
11
|
+
#
|
12
|
+
module Result
|
13
|
+
#
|
14
|
+
# データ部
|
15
|
+
#
|
16
|
+
module Data
|
17
|
+
#
|
18
|
+
# Option オプション
|
19
|
+
#
|
20
|
+
module Option
|
21
|
+
#
|
22
|
+
# VanishedDate 滅日
|
23
|
+
#
|
24
|
+
module VanishedDate
|
25
|
+
#
|
26
|
+
# Option 滅日集約
|
27
|
+
#
|
28
|
+
class Option < AbstractOption
|
29
|
+
# @return [Calculation] 演算値
|
30
|
+
attr_reader :calculation
|
31
|
+
|
32
|
+
#
|
33
|
+
# 初期化
|
34
|
+
#
|
35
|
+
# @param [True, False] matched オプション値有無
|
36
|
+
# @param [Calculation] calculation 演算値
|
37
|
+
#
|
38
|
+
def initialize(matched: false, calculation: Calculation.new)
|
39
|
+
super(matched: matched)
|
40
|
+
@calculation = calculation
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -29,6 +29,12 @@ module Zakuro
|
|
29
29
|
#
|
30
30
|
# @return [Cycle::Remainder] 弦(1分=80秒)
|
31
31
|
QUARTER = Cycle::Remainder.new(day: 7, minute: 1163, second: 6)
|
32
|
+
|
33
|
+
# @return [Cycle::Remainder] 有没判定
|
34
|
+
DROPPED_DATE_LIMIT = Cycle::Remainder.new(day: 0, minute: 2375, second: 17)
|
35
|
+
|
36
|
+
# @return [Cycle::Remainder] 有滅判定
|
37
|
+
VANISHED_DATE_LIMIT = Cycle::Remainder.new(day: 0, minute: 1427, second: 0)
|
32
38
|
end
|
33
39
|
|
34
40
|
#
|
@@ -44,8 +50,7 @@ module Zakuro
|
|
44
50
|
# * 0.25 * 80(1分=80秒) = 20
|
45
51
|
#
|
46
52
|
# @return [Cycle::LunarRemainder] 弦(1分=80秒)
|
47
|
-
|
48
|
-
QUARTER = Cycle::LunarRemainder.new(day: 7, minute: 1163, second: 20.01247)
|
53
|
+
QUARTER = Cycle::LunarRemainder.new(day: 7, minute: 1163, second: 20)
|
49
54
|
end
|
50
55
|
end
|
51
56
|
end
|
@@ -32,19 +32,6 @@ module Zakuro
|
|
32
32
|
super(base_day: Const::Number::Cycle::DAY, base_minute: MINUTE,
|
33
33
|
day: day, minute: minute, second: second, total: total)
|
34
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
35
|
end
|
49
36
|
|
50
37
|
#
|
@@ -66,18 +53,49 @@ module Zakuro
|
|
66
53
|
super(base_day: Const::Number::Cycle::DAY, base_minute: MINUTE,
|
67
54
|
day: day, minute: minute, second: second, total: total)
|
68
55
|
end
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# DroppedRemainder 没日の計算向け時刻情報(没余)
|
60
|
+
#
|
61
|
+
class DroppedRemainder < Calculation::Cycle::AbstractRemainder
|
62
|
+
# @return [Integer] 分(1分=24秒)
|
63
|
+
MINUTE = 24
|
69
64
|
|
70
65
|
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
# @param [String] form フォーマット(大余、小余、秒それぞれを%dで指定する)
|
66
|
+
# 初期化
|
74
67
|
#
|
75
|
-
# @
|
68
|
+
# @param [Integer] day 大余("日"に相当)
|
69
|
+
# @param [Integer] minute 小余("分"に相当)
|
70
|
+
# @param [Integer] second 秒
|
71
|
+
# @param [Integer] total 繰り上げなしの小余
|
76
72
|
#
|
77
|
-
def
|
78
|
-
|
73
|
+
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
74
|
+
# 小余 = 通余
|
75
|
+
super(base_day: Const::Number::Derivation::REMAINDER_ALL_YEAR, base_minute: MINUTE,
|
76
|
+
day: day, minute: minute, second: second, total: total)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# VanishedRemainder 滅日の計算向け時刻情報(滅余)
|
82
|
+
#
|
83
|
+
class VanishedRemainder < Calculation::Cycle::AbstractRemainder
|
84
|
+
# @return [Integer] 分(1分=24秒)
|
85
|
+
MINUTE = 24
|
79
86
|
|
80
|
-
|
87
|
+
#
|
88
|
+
# 初期化
|
89
|
+
#
|
90
|
+
# @param [Integer] day 大余("日"に相当)
|
91
|
+
# @param [Integer] minute 小余("分"に相当)
|
92
|
+
# @param [Integer] second 秒
|
93
|
+
# @param [Integer] total 繰り上げなしの小余
|
94
|
+
#
|
95
|
+
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
96
|
+
# 小余 = 朔虚分
|
97
|
+
super(base_day: Const::Number::Derivation::REMAINDER_IDEAL_MONTH, base_minute: MINUTE,
|
98
|
+
day: day, minute: minute, second: second, total: total)
|
81
99
|
end
|
82
100
|
end
|
83
101
|
end
|
@@ -64,7 +64,7 @@ module Zakuro
|
|
64
64
|
# NOTE: 大衍暦では進朔しない
|
65
65
|
# adjusted.up_on_new_moon!
|
66
66
|
|
67
|
-
debug("result: #{adjusted.format}")
|
67
|
+
debug("result: #{adjusted.format(form: '%d-%d.%.5f')}")
|
68
68
|
|
69
69
|
adjusted
|
70
70
|
end
|
@@ -92,9 +92,7 @@ module Zakuro
|
|
92
92
|
|
93
93
|
remainder = lunar_location.adjusted_remainder
|
94
94
|
|
95
|
-
|
96
|
-
# debug("[lunar]remainder.day: #{remainder.day}")
|
97
|
-
# debug("[lunar]remainder.minute: #{remainder.minute}")
|
95
|
+
debug("[lunar]remainder.format: #{remainder.format(form: '%d-%d-%.5f')}")
|
98
96
|
|
99
97
|
Lunar::Value.get(remainder: remainder)
|
100
98
|
end
|
@@ -9,9 +9,9 @@ require_relative '../../cycle/remainder'
|
|
9
9
|
# :nodoc:
|
10
10
|
module Zakuro
|
11
11
|
# :nodoc:
|
12
|
-
module
|
12
|
+
module Daien
|
13
13
|
# :nodoc:
|
14
|
-
module
|
14
|
+
module Option
|
15
15
|
# :nodoc:
|
16
16
|
module DroppedDate
|
17
17
|
#
|
@@ -22,7 +22,9 @@ module Zakuro
|
|
22
22
|
# 初期化
|
23
23
|
#
|
24
24
|
def initialize
|
25
|
-
super(valid:
|
25
|
+
super(valid: true, year: Const::Number::Cycle::YEAR,
|
26
|
+
limit: Const::Remainder::Solar::DROPPED_DATE_LIMIT,
|
27
|
+
remainder_class: Cycle::DroppedRemainder)
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|