zakuro 0.6.0 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +3 -0
- data/README.md +58 -16
- data/VERSION +1 -1
- data/doc/dropped_date.md +93 -0
- data/doc/error.md +45 -0
- data/doc/operation/transfer.rb +8 -8
- data/lib/zakuro/calculation/base/day.rb +52 -0
- data/lib/zakuro/calculation/base/gengou.rb +50 -4
- data/lib/zakuro/calculation/base/linear_gengou.rb +6 -6
- data/lib/zakuro/calculation/base/operated_year.rb +3 -3
- data/lib/zakuro/calculation/base/year.rb +4 -4
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +5 -3
- data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +209 -0
- data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +30 -0
- data/lib/zakuro/calculation/era/gengou/internal/connector.rb +107 -0
- data/lib/zakuro/calculation/era/gengou/internal/counter.rb +214 -0
- data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +104 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +230 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +193 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +48 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +30 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +158 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +125 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +75 -0
- data/lib/zakuro/calculation/{gengou → era/gengou}/internal/reserve.rb +6 -7
- data/lib/zakuro/calculation/era/gengou/named_scroll.rb +30 -0
- data/lib/zakuro/calculation/{version → era/version}/internal/crawler.rb +7 -7
- data/lib/zakuro/calculation/{version → era/version}/internal/range.rb +4 -4
- data/lib/zakuro/calculation/{version → era/version}/version.rb +3 -3
- data/lib/zakuro/calculation/monthly/initialized_month.rb +1 -1
- data/lib/zakuro/calculation/monthly/month.rb +44 -5
- data/lib/zakuro/calculation/monthly/operated_month.rb +2 -2
- data/lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb +44 -0
- data/lib/zakuro/calculation/option/dropped_date/location.rb +135 -0
- data/lib/zakuro/calculation/range/{full_range.rb → abstract_full_range.rb} +29 -27
- data/lib/zakuro/calculation/range/{operated_range.rb → abstract_operation_range.rb} +11 -14
- data/lib/zakuro/calculation/range/dated_full_range.rb +32 -0
- data/lib/zakuro/calculation/range/dated_operation_range.rb +33 -0
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +2 -2
- data/lib/zakuro/calculation/range/named_full_range.rb +38 -0
- data/lib/zakuro/calculation/range/named_operation_range.rb +36 -0
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +9 -11
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +6 -6
- data/lib/zakuro/calculation/stella/solar/abstract_location.rb +2 -0
- data/lib/zakuro/calculation/summary/internal/day.rb +40 -0
- data/lib/zakuro/calculation/summary/internal/month.rb +92 -0
- data/lib/zakuro/calculation/summary/{single.rb → internal/operation.rb} +6 -40
- data/lib/zakuro/calculation/summary/internal/option.rb +85 -0
- data/lib/zakuro/calculation/summary/japan/range.rb +158 -0
- data/lib/zakuro/calculation/summary/japan/single.rb +118 -0
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +96 -0
- data/lib/zakuro/calculation/summary/western/range.rb +124 -0
- data/lib/zakuro/calculation/summary/western/single.rb +113 -0
- data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +174 -0
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +98 -0
- data/lib/zakuro/calculation/type/optional.rb +46 -0
- data/lib/zakuro/condition.rb +75 -22
- data/lib/zakuro/context/context.rb +44 -0
- data/lib/zakuro/context/option.rb +117 -0
- data/lib/zakuro/context/version_class_resolver.rb +110 -0
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +125 -0
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +168 -0
- data/lib/zakuro/era/japan/gengou/alignment/line.rb +175 -0
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +187 -0
- data/lib/zakuro/era/japan/gengou/alignment.rb +55 -0
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +245 -0
- data/lib/zakuro/era/japan/gengou/resource/type.rb +299 -0
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +347 -0
- data/lib/zakuro/era/japan/gengou/{yaml → resource/yaml}/set-001-until-south.yaml +2 -2
- data/lib/zakuro/era/japan/gengou/{yaml → resource/yaml}/set-002-from-north.yaml +2 -2
- data/lib/zakuro/era/japan/gengou/{yaml → resource/yaml}/set-003-modern.yaml +2 -2
- data/lib/zakuro/era/japan/gengou/resource.rb +33 -0
- data/lib/zakuro/era/japan/gengou.rb +25 -79
- data/lib/zakuro/era/japan/version.rb +18 -18
- data/lib/zakuro/era/western/calendar.rb +13 -9
- data/lib/zakuro/exception/case/pattern.rb +71 -0
- data/lib/zakuro/exception/case/preset.rb +51 -0
- data/lib/zakuro/exception/case/template.rb +48 -0
- data/lib/zakuro/exception/cause.rb +28 -0
- data/lib/zakuro/exception/exception.rb +37 -0
- data/lib/zakuro/exception/zakuro_error.rb +46 -0
- data/lib/zakuro/gateway/locale/date.rb +127 -0
- data/lib/zakuro/gateway/locale/range.rb +67 -0
- data/lib/zakuro/gateway/range.rb +99 -0
- data/lib/zakuro/gateway/single.rb +70 -0
- data/lib/zakuro/merchant.rb +84 -12
- data/lib/zakuro/operation/month/parser.rb +11 -9
- data/lib/zakuro/operation/month/type.rb +31 -31
- data/lib/zakuro/operation/month/validator.rb +50 -50
- data/lib/zakuro/operation/yaml/month.yaml +3736 -3736
- data/lib/zakuro/output/logger.rb +17 -3
- data/lib/zakuro/output/response.rb +24 -57
- data/lib/zakuro/result/data/day.rb +43 -0
- data/lib/zakuro/result/data/gengou.rb +35 -0
- data/lib/zakuro/result/data/month.rb +63 -0
- data/lib/zakuro/result/data/option/abstract_option.rb +37 -0
- data/lib/zakuro/result/data/option/dropped_date/calculation.rb +47 -0
- data/lib/zakuro/result/data/option/dropped_date/option.rb +47 -0
- data/lib/zakuro/result/data/option/dropped_date/solar_term.rb +48 -0
- data/lib/zakuro/result/data/single_day.rb +56 -0
- data/lib/zakuro/result/data/solar_term.rb +35 -0
- data/lib/zakuro/result/data/year.rb +45 -0
- data/lib/zakuro/result/operation/bundle.rb +44 -0
- data/lib/zakuro/result/operation/month/annotation.rb +40 -0
- data/lib/zakuro/result/operation/month/bundle.rb +36 -0
- data/lib/zakuro/result/operation/month/history.rb +54 -0
- data/lib/zakuro/result/result.rb +21 -2
- data/lib/zakuro/tools/stringifier.rb +26 -3
- data/lib/zakuro/version/daien/cycle/remainder.rb +2 -2
- data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/daien/range/annual_range.rb +1 -1
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +2 -0
- data/lib/zakuro/version/daien/stella/lunar/value.rb +2 -0
- data/lib/zakuro/version/genka/cycle/remainder.rb +2 -2
- data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/genka/range/annual_range.rb +1 -1
- data/lib/zakuro/version/gihou/cycle/remainder.rb +2 -2
- data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/gihou/range/annual_range.rb +1 -1
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +2 -0
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +2 -0
- data/lib/zakuro/version/senmyou/README.md +11 -7
- data/lib/zakuro/version/senmyou/const/remainder.rb +5 -0
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +37 -2
- data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +33 -0
- data/lib/zakuro/version/senmyou/range/annual_range.rb +1 -1
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +2 -0
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +2 -0
- metadata +85 -24
- data/lib/zakuro/calculation/gengou/internal/counter.rb +0 -129
- data/lib/zakuro/calculation/gengou/internal/reserve/interval.rb +0 -183
- data/lib/zakuro/calculation/gengou/internal/reserve/list.rb +0 -382
- data/lib/zakuro/calculation/gengou/scroll.rb +0 -262
- data/lib/zakuro/calculation/specifier/single_day.rb +0 -87
- data/lib/zakuro/era/japan/gengou/parser.rb +0 -237
- data/lib/zakuro/era/japan/gengou/type.rb +0 -285
- data/lib/zakuro/era/japan/gengou/validator.rb +0 -341
- data/lib/zakuro/result/data.rb +0 -187
- data/lib/zakuro/result/operation.rb +0 -114
- data/lib/zakuro/version/context.rb +0 -44
- data/lib/zakuro/version/version_class_resolver.rb +0 -74
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :nodoc:
|
4
|
+
module Zakuro
|
5
|
+
#
|
6
|
+
# Result 演算結果
|
7
|
+
#
|
8
|
+
module Result
|
9
|
+
#
|
10
|
+
# 運用情報
|
11
|
+
#
|
12
|
+
module Operation
|
13
|
+
#
|
14
|
+
# Month 運用情報(月)
|
15
|
+
#
|
16
|
+
module Month
|
17
|
+
#
|
18
|
+
# Annotation 注釈
|
19
|
+
#
|
20
|
+
class Annotation
|
21
|
+
# @return [String] 注釈内容
|
22
|
+
attr_reader :description
|
23
|
+
# @return [String] 注釈補記
|
24
|
+
attr_reader :note
|
25
|
+
|
26
|
+
#
|
27
|
+
# 初期化
|
28
|
+
#
|
29
|
+
# @param [String] description 注釈内容
|
30
|
+
# @param [<Type>] note 注釈補記
|
31
|
+
#
|
32
|
+
def initialize(description:, note:)
|
33
|
+
@description = description
|
34
|
+
@note = note
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './history'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
#
|
8
|
+
# Result 演算結果
|
9
|
+
#
|
10
|
+
module Result
|
11
|
+
#
|
12
|
+
# 運用情報
|
13
|
+
#
|
14
|
+
module Operation
|
15
|
+
#
|
16
|
+
# Month 運用情報(月)
|
17
|
+
#
|
18
|
+
module Month
|
19
|
+
#
|
20
|
+
# Bundle 月履歴集約情報
|
21
|
+
#
|
22
|
+
class Bundle
|
23
|
+
# @return [History] 月別履歴情報(当月)
|
24
|
+
attr_reader :current
|
25
|
+
# @return [History] 月別履歴情報(影響を与えた月)
|
26
|
+
attr_reader :parent
|
27
|
+
|
28
|
+
def initialize(current: History.new, parent: History.new)
|
29
|
+
@current = current
|
30
|
+
@parent = parent
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './annotation'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
#
|
8
|
+
# Result 演算結果
|
9
|
+
#
|
10
|
+
module Result
|
11
|
+
#
|
12
|
+
# 運用情報
|
13
|
+
#
|
14
|
+
module Operation
|
15
|
+
#
|
16
|
+
# Month 運用情報(月)
|
17
|
+
#
|
18
|
+
module Month
|
19
|
+
#
|
20
|
+
# History 月別履歴情報
|
21
|
+
#
|
22
|
+
class History
|
23
|
+
# @return [String] ID
|
24
|
+
attr_reader :id
|
25
|
+
# @return [String] 月初日の西暦日
|
26
|
+
attr_reader :western_date
|
27
|
+
# @return [Integer] 原文頁数
|
28
|
+
attr_reader :page
|
29
|
+
# @return [Integer] 原文注釈番号
|
30
|
+
attr_reader :number
|
31
|
+
# @return [Array<Annotation>] 注釈
|
32
|
+
attr_reader :annotations
|
33
|
+
|
34
|
+
#
|
35
|
+
# 初期化
|
36
|
+
#
|
37
|
+
# @param [String] id ID
|
38
|
+
# @param [String] western_date 月初日の西暦日
|
39
|
+
# @param [Integer] page 原文頁数
|
40
|
+
# @param [Integer] number 原文注釈番号
|
41
|
+
# @param [Array<Annotation>] annotations 注釈
|
42
|
+
#
|
43
|
+
def initialize(id: '', western_date: '', page: -1, number: -1, annotations: [])
|
44
|
+
@id = id
|
45
|
+
@western_date = western_date
|
46
|
+
@page = page
|
47
|
+
@number = number
|
48
|
+
@annotations = annotations
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/zakuro/result/result.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'json'
|
4
4
|
|
5
|
+
require_relative './data/single_day'
|
6
|
+
|
7
|
+
require_relative './operation/bundle'
|
8
|
+
|
5
9
|
require_relative './core'
|
6
|
-
require_relative './data'
|
7
|
-
require_relative './operation'
|
8
10
|
|
9
11
|
# :nodoc:
|
10
12
|
module Zakuro
|
@@ -33,5 +35,22 @@ module Zakuro
|
|
33
35
|
@operation = operation
|
34
36
|
end
|
35
37
|
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Range 期間検索結果
|
41
|
+
#
|
42
|
+
class Range < Core
|
43
|
+
attr_reader :list
|
44
|
+
|
45
|
+
#
|
46
|
+
# 初期化
|
47
|
+
#
|
48
|
+
# @param [Array<Data::Single>] list 期間内データ
|
49
|
+
#
|
50
|
+
def initialize(list: [])
|
51
|
+
super
|
52
|
+
@list = list
|
53
|
+
end
|
54
|
+
end
|
36
55
|
end
|
37
56
|
end
|
@@ -17,6 +17,7 @@ module Zakuro
|
|
17
17
|
#
|
18
18
|
# @param [Object] obj 対象インスタンス
|
19
19
|
# @param [String] class_prefix インスタンス内でハッシュ変換するクラスのプレフィックス
|
20
|
+
# @param [True, False] formatted 整形有無
|
20
21
|
#
|
21
22
|
# @return [Hash<String, Objcet>] ハッシュ
|
22
23
|
#
|
@@ -31,13 +32,12 @@ module Zakuro
|
|
31
32
|
hash
|
32
33
|
end
|
33
34
|
|
34
|
-
# :reek:TooManyStatements { max_statements: 7 }
|
35
|
-
|
36
35
|
#
|
37
36
|
# 対象インスタンスをハッシュ化する(再帰処理)
|
38
37
|
#
|
39
38
|
# @param [Object] obj 対象インスタンス
|
40
39
|
# @param [String] class_prefix インスタンス内でハッシュ変換するクラスのプレフィックス
|
40
|
+
# @param [True, False] formatted 整形有無
|
41
41
|
#
|
42
42
|
# @return [Hash<String, Objcet>] ハッシュ
|
43
43
|
#
|
@@ -52,6 +52,20 @@ module Zakuro
|
|
52
52
|
return to_h(obj: obj, class_prefix: class_prefix, formatted: formatted)
|
53
53
|
end
|
54
54
|
|
55
|
+
general_value_to_hash(obj: obj, class_prefix: class_prefix, formatted: formatted)
|
56
|
+
end
|
57
|
+
private_class_method :value_to_hash
|
58
|
+
|
59
|
+
#
|
60
|
+
# ライブラリを問わない標準的な値をハッシュ化する(再帰処理)
|
61
|
+
#
|
62
|
+
# @param [Object] obj 対象インスタンス
|
63
|
+
# @param [String] class_prefix インスタンス内でハッシュ変換するクラスのプレフィックス
|
64
|
+
# @param [True, False] formatted 整形有無
|
65
|
+
#
|
66
|
+
# @return [Objcet] ハッシュ変換可能な値
|
67
|
+
#
|
68
|
+
def self.general_value_to_hash(obj:, class_prefix:, formatted:)
|
55
69
|
# 配列は要素一つずつで再帰する
|
56
70
|
if obj.is_a?(Array)
|
57
71
|
arr = []
|
@@ -61,9 +75,18 @@ module Zakuro
|
|
61
75
|
return arr
|
62
76
|
end
|
63
77
|
|
78
|
+
# ハッシュはキーごとに再帰する
|
79
|
+
if obj.is_a?(Hash)
|
80
|
+
hash = {}
|
81
|
+
obj.each do |key, value|
|
82
|
+
hash[key] = to_h(obj: value, class_prefix: class_prefix, formatted: formatted)
|
83
|
+
end
|
84
|
+
return hash
|
85
|
+
end
|
86
|
+
|
64
87
|
obj
|
65
88
|
end
|
66
|
-
private_class_method :
|
89
|
+
private_class_method :general_value_to_hash
|
67
90
|
end
|
68
91
|
end
|
69
92
|
end
|
@@ -29,7 +29,7 @@ module Zakuro
|
|
29
29
|
# @param [Integer] total 繰り上げなしの小余
|
30
30
|
#
|
31
31
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
32
|
-
super(base_day: Const::Number::Cycle::DAY,
|
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
35
|
|
@@ -63,7 +63,7 @@ module Zakuro
|
|
63
63
|
# @param [Integer] total 繰り上げなしの小余
|
64
64
|
#
|
65
65
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
66
|
-
super(base_day: Const::Number::Cycle::DAY,
|
66
|
+
super(base_day: Const::Number::Cycle::DAY, base_minute: MINUTE,
|
67
67
|
day: day, minute: minute, second: second, total: total)
|
68
68
|
end
|
69
69
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../calculation/option/dropped_date/abstract_parameter'
|
4
|
+
|
5
|
+
require_relative '../../const/number'
|
6
|
+
require_relative '../../const/remainder'
|
7
|
+
require_relative '../../cycle/remainder'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
# :nodoc:
|
12
|
+
module Senmyou
|
13
|
+
# :nodoc:
|
14
|
+
module Daien
|
15
|
+
# :nodoc:
|
16
|
+
module DroppedDate
|
17
|
+
#
|
18
|
+
# Parameter 引数
|
19
|
+
#
|
20
|
+
class Parameter < Calculation::Option::DroppedDate::AbstractParameter
|
21
|
+
#
|
22
|
+
# 初期化
|
23
|
+
#
|
24
|
+
def initialize
|
25
|
+
super(valid: false)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -30,7 +30,7 @@ module Zakuro
|
|
30
30
|
# @param [Integer] total 繰り上げなしの小余
|
31
31
|
#
|
32
32
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
33
|
-
super(base_day: Const::Number::Cycle::DAY,
|
33
|
+
super(base_day: Const::Number::Cycle::DAY, base_minute: MINUTE,
|
34
34
|
day: day, minute: minute, second: second, total: total)
|
35
35
|
end
|
36
36
|
|
@@ -67,7 +67,7 @@ module Zakuro
|
|
67
67
|
# @param [Integer] total 繰り上げなしの小余
|
68
68
|
#
|
69
69
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
70
|
-
super(base_day: Const::Number::Cycle::TERM_DAY,
|
70
|
+
super(base_day: Const::Number::Cycle::TERM_DAY, base_minute: MINUTE,
|
71
71
|
day: day, minute: minute, second: second, total: total)
|
72
72
|
end
|
73
73
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../calculation/option/dropped_date/abstract_parameter'
|
4
|
+
|
5
|
+
require_relative '../../const/number'
|
6
|
+
require_relative '../../const/remainder'
|
7
|
+
require_relative '../../cycle/remainder'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
# :nodoc:
|
12
|
+
module Genka
|
13
|
+
# :nodoc:
|
14
|
+
module Option
|
15
|
+
# :nodoc:
|
16
|
+
module DroppedDate
|
17
|
+
#
|
18
|
+
# Parameter 引数
|
19
|
+
#
|
20
|
+
class Parameter < Calculation::Option::DroppedDate::AbstractParameter
|
21
|
+
#
|
22
|
+
# 初期化
|
23
|
+
#
|
24
|
+
def initialize
|
25
|
+
super(valid: false)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -26,7 +26,7 @@ module Zakuro
|
|
26
26
|
# @param [Integer] total 繰り上げなしの小余
|
27
27
|
#
|
28
28
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
29
|
-
super(base_day: Const::Number::Cycle::DAY,
|
29
|
+
super(base_day: Const::Number::Cycle::DAY, base_minute: MINUTE,
|
30
30
|
day: day, minute: minute, second: second, total: total)
|
31
31
|
end
|
32
32
|
|
@@ -60,7 +60,7 @@ module Zakuro
|
|
60
60
|
# @param [Integer] total 繰り上げなしの小余
|
61
61
|
#
|
62
62
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
63
|
-
super(base_day: Const::Number::Cycle::DAY,
|
63
|
+
super(base_day: Const::Number::Cycle::DAY, base_minute: MINUTE,
|
64
64
|
day: day, minute: minute, second: second, total: total)
|
65
65
|
end
|
66
66
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../calculation/option/dropped_date/abstract_parameter'
|
4
|
+
|
5
|
+
require_relative '../../const/number'
|
6
|
+
require_relative '../../const/remainder'
|
7
|
+
require_relative '../../cycle/remainder'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
# :nodoc:
|
12
|
+
module Gihou
|
13
|
+
# :nodoc:
|
14
|
+
module Option
|
15
|
+
# :nodoc:
|
16
|
+
module DroppedDate
|
17
|
+
#
|
18
|
+
# Parameter 引数
|
19
|
+
#
|
20
|
+
class Parameter < Calculation::Option::DroppedDate::AbstractParameter
|
21
|
+
#
|
22
|
+
# 初期化
|
23
|
+
#
|
24
|
+
def initialize
|
25
|
+
super(valid: false)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -94,21 +94,25 @@
|
|
94
94
|
|
95
95
|
計算の多くはそれぞれの暦に依存するが、まずは共通の計算部分を列挙する
|
96
96
|
|
97
|
-
###
|
97
|
+
### 元号の求め方
|
98
98
|
|
99
|
-
|
99
|
+
元慶(877-6-1 ~ 885-3-10)をもとに考える
|
100
100
|
|
101
|
-
|
101
|
+
元号開始年が存在する元号年(877)から、次の元号の開始年(885) + 1 までを和暦計算する。これをAとする
|
102
102
|
|
103
|
-
|
103
|
+
元号のはじまりは固定値のため、西暦開始日と、それに対応する和暦開始日を持つ(例: 元慶01年04月16日 = 877-6-1)
|
104
104
|
|
105
|
-
|
105
|
+
この和暦開始日は必ずAの1年目に存在するため、1年目の和暦日を特定し、その日と西暦開始日を関連付ける
|
106
106
|
|
107
|
-
|
107
|
+
もし元慶2年以降を計算したい場合は、Aの西暦開始日から該当年月日までを加算で求める
|
108
|
+
|
109
|
+
具体的には、和暦上の月の大小(29日 or 30日)を用いた加算となる
|
110
|
+
|
111
|
+
念のため補足するが、西暦(太陽暦)のように1年あたりの日数は一定しない
|
108
112
|
|
109
113
|
平年(353/354/355/356)または閏年(383/384/385)のパターンがあり、月の大小(29/30)や閏月(中気のない月)の有無で変動する
|
110
114
|
|
111
|
-
|
115
|
+
したがって、2年目以降を加算なしに特定することはできない
|
112
116
|
|
113
117
|
### 南北朝について
|
114
118
|
|
@@ -25,6 +25,11 @@ module Zakuro
|
|
25
25
|
#
|
26
26
|
# @return [Cycle::Remainder] 弦(1分=8秒)
|
27
27
|
QUARTER = Cycle::Remainder.new(day: 7, minute: 3214, second: 2)
|
28
|
+
|
29
|
+
# @return [Cycle::Remainder] 有没判定
|
30
|
+
# * 中盈(小余3671秒2)/ 2 = 小余1835秒5
|
31
|
+
# * 日(小余8400) - 小余1835秒5 = 小余6564秒3
|
32
|
+
DROPPED_DATE_LIMIT = Cycle::Remainder.new(day: 0, minute: 6564, second: 3)
|
28
33
|
end
|
29
34
|
|
30
35
|
#
|
@@ -26,7 +26,7 @@ module Zakuro
|
|
26
26
|
# @param [Integer] total 繰り上げなしの小余
|
27
27
|
#
|
28
28
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
29
|
-
super(base_day: Const::Number::Cycle::DAY,
|
29
|
+
super(base_day: Const::Number::Cycle::DAY, base_minute: MINUTE,
|
30
30
|
day: day, minute: minute, second: second, total: total)
|
31
31
|
end
|
32
32
|
|
@@ -60,7 +60,42 @@ module Zakuro
|
|
60
60
|
# @param [Integer] total 繰り上げなしの小余
|
61
61
|
#
|
62
62
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
63
|
-
super(base_day: Const::Number::Cycle::DAY,
|
63
|
+
super(base_day: Const::Number::Cycle::DAY, base_minute: MINUTE,
|
64
|
+
day: day, minute: minute, second: second, total: total)
|
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
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# DroppedRemainder 没日の計算向け時刻情報(没余)
|
83
|
+
#
|
84
|
+
class DroppedRemainder < Calculation::Cycle::AbstractRemainder
|
85
|
+
# @return [Integer] 分(1分=8秒)
|
86
|
+
MINUTE = 8
|
87
|
+
|
88
|
+
#
|
89
|
+
# 初期化
|
90
|
+
#
|
91
|
+
# @param [Integer] day 大余("日"に相当)
|
92
|
+
# @param [Integer] minute 小余("分"に相当)
|
93
|
+
# @param [Integer] second 秒
|
94
|
+
# @param [Integer] total 繰り上げなしの小余
|
95
|
+
#
|
96
|
+
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
97
|
+
# 小余 = 通余
|
98
|
+
super(base_day: Const::Number::Derivation::REMAINDER_ALL_YEAR, base_minute: MINUTE,
|
64
99
|
day: day, minute: minute, second: second, total: total)
|
65
100
|
end
|
66
101
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../calculation/option/dropped_date/abstract_parameter'
|
4
|
+
|
5
|
+
require_relative '../../const/number'
|
6
|
+
require_relative '../../const/remainder'
|
7
|
+
require_relative '../../cycle/remainder'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
# :nodoc:
|
12
|
+
module Senmyou
|
13
|
+
# :nodoc:
|
14
|
+
module Option
|
15
|
+
# :nodoc:
|
16
|
+
module DroppedDate
|
17
|
+
#
|
18
|
+
# Parameter 引数
|
19
|
+
#
|
20
|
+
class Parameter < Calculation::Option::DroppedDate::AbstractParameter
|
21
|
+
#
|
22
|
+
# 初期化
|
23
|
+
#
|
24
|
+
def initialize
|
25
|
+
super(valid: true, year: Const::Number::Cycle::YEAR,
|
26
|
+
limit: Const::Remainder::Solar::DROPPED_DATE_LIMIT,
|
27
|
+
remainder_class: Cycle::DroppedRemainder)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|