zakuro 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -3
- data/VERSION +1 -1
- data/lib/zakuro/calculation/base/gengou.rb +4 -4
- data/lib/zakuro/calculation/base/linear_gengou.rb +6 -6
- 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/list.rb +244 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/range.rb +193 -0
- data/lib/zakuro/calculation/{gengou → era/gengou}/internal/reserve.rb +6 -6
- data/lib/zakuro/calculation/{gengou → era/gengou}/scroll.rb +44 -95
- 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/month.rb +2 -2
- data/lib/zakuro/calculation/range/full_range.rb +18 -19
- data/lib/zakuro/calculation/range/operated_range.rb +3 -4
- data/lib/zakuro/calculation/specifier/internal/month.rb +84 -0
- data/lib/zakuro/calculation/specifier/multiple_day.rb +162 -0
- data/lib/zakuro/calculation/specifier/single_day.rb +2 -2
- data/lib/zakuro/calculation/summary/internal/operation.rb +98 -0
- data/lib/zakuro/calculation/summary/range.rb +120 -0
- data/lib/zakuro/calculation/summary/single.rb +45 -67
- data/lib/zakuro/condition.rb +14 -0
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +106 -0
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +165 -0
- data/lib/zakuro/era/japan/gengou/alignment/line.rb +156 -0
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +184 -0
- data/lib/zakuro/era/japan/gengou/alignment.rb +42 -0
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +242 -0
- data/lib/zakuro/era/japan/gengou/resource/type.rb +292 -0
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +346 -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 +32 -0
- data/lib/zakuro/era/japan/gengou.rb +34 -73
- data/lib/zakuro/era/japan/version.rb +18 -18
- data/lib/zakuro/merchant.rb +41 -3
- data/lib/zakuro/operation/month/validator.rb +1 -1
- data/lib/zakuro/result/result.rb +17 -0
- data/lib/zakuro/version/senmyou/README.md +11 -7
- metadata +32 -20
- 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/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
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../western/calendar'
|
4
|
-
|
5
|
-
require_relative './gengou/
|
4
|
+
|
5
|
+
require_relative './gengou/alignment'
|
6
6
|
|
7
7
|
# :nodoc:
|
8
8
|
module Zakuro
|
@@ -11,95 +11,56 @@ module Zakuro
|
|
11
11
|
#
|
12
12
|
module Japan
|
13
13
|
#
|
14
|
-
#
|
14
|
+
# Gengou 元号
|
15
15
|
#
|
16
|
-
module
|
17
|
-
# @return [
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
__dir__
|
22
|
-
)),
|
23
|
-
Parser.run(filepath: File.expand_path(
|
24
|
-
'./gengou/yaml/set-002-from-north.yaml',
|
25
|
-
__dir__
|
26
|
-
)),
|
27
|
-
Parser.run(filepath: File.expand_path(
|
28
|
-
'./gengou/yaml/set-003-modern.yaml',
|
29
|
-
__dir__
|
30
|
-
))
|
31
|
-
].freeze
|
32
|
-
|
33
|
-
# :reek:TooManyStatements { max_statements: 9 }
|
34
|
-
|
35
|
-
#
|
36
|
-
# 元号(1行目,2行目)を引き当てる
|
37
|
-
#
|
38
|
-
# * LIST配列の元号情報を配列順で「x行目」(1始まり)とする
|
39
|
-
# * 1行目にデータがあれば、第一要素に1行目のデータが設定される
|
40
|
-
# * 1行目と2行目にデータがあれば、第二要素に2行目のデータが設定される
|
41
|
-
# * 1行目にデータがなく、2行目以降に1つだけデータがあれば、第一要素にそのデータを設定してそれ以外の要素は未設定
|
42
|
-
# * 1行目にデータがなく、2行目以降に2つ以上のデータがあれば、第一要素に末尾行に一番近いデータを設定してそれ以外の要素は未設定
|
43
|
-
#
|
44
|
-
# @param [Western::Calendar] date 日
|
45
|
-
#
|
46
|
-
# @return [Array<Gengou>] 元号情報(1行目, 2行目)
|
47
|
-
#
|
48
|
-
def self.lines(date:)
|
49
|
-
lines = native_lines(date: date)
|
50
|
-
return lines unless lines[0].invalid?
|
51
|
-
|
52
|
-
first = Japan::Gengou.new
|
53
|
-
lines[1..].each.with_index(1) do |item, index|
|
54
|
-
next if item.invalid?
|
16
|
+
module Gengou
|
17
|
+
# @return [Integer] 1行目
|
18
|
+
FIRST_LINE = Alignment::Aligner::FIRST_LINE
|
19
|
+
# @return [Integer] 2行目
|
20
|
+
SECOND_LINE = Alignment::Aligner::SECOND_LINE
|
55
21
|
|
56
|
-
first = item
|
57
|
-
lines[index] = Japan::Gengou.new
|
58
|
-
end
|
59
|
-
lines[0] = first
|
60
|
-
lines
|
61
|
-
end
|
62
|
-
|
63
|
-
#
|
64
|
-
# 元号を引き当てる
|
65
22
|
#
|
66
|
-
#
|
67
|
-
# * 1行目,2行目といった概念は無視する
|
23
|
+
# 該当行の元号を取得する
|
68
24
|
#
|
69
|
-
# @param [
|
25
|
+
# @param [Integer] line 行番号
|
26
|
+
# @param [Western::Calendar] start_date 開始日
|
27
|
+
# @param [Western::Calendar] last_date 終了日
|
70
28
|
#
|
71
|
-
# @return [Array<
|
29
|
+
# @return [Array<LinearGengou>] 該当行の元号
|
72
30
|
#
|
73
|
-
def self.
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
result
|
31
|
+
def self.line(line: FIRST_LINE,
|
32
|
+
start_date: Western::Calendar.new, last_date: Western::Calendar.new)
|
33
|
+
Alignment.get(
|
34
|
+
line: line, start_date: start_date, last_date: last_date
|
35
|
+
)
|
79
36
|
end
|
80
37
|
|
81
38
|
#
|
82
|
-
#
|
39
|
+
# 1行目元号を取得する
|
83
40
|
#
|
84
|
-
# @param [Western::Calendar]
|
41
|
+
# @param [Western::Calendar] start_date 開始日
|
42
|
+
# @param [Western::Calendar] last_date 終了日
|
85
43
|
#
|
86
|
-
# @return [
|
44
|
+
# @return [Array<LinearGengou>] 1行目元号
|
87
45
|
#
|
88
|
-
def self.first_line(
|
89
|
-
|
90
|
-
|
46
|
+
def self.first_line(start_date: Western::Calendar.new, last_date: Western::Calendar.new)
|
47
|
+
Alignment.get(
|
48
|
+
line: FIRST_LINE, start_date: start_date, last_date: last_date
|
49
|
+
)
|
91
50
|
end
|
92
51
|
|
93
52
|
#
|
94
|
-
#
|
53
|
+
# 2行目元号を取得する
|
95
54
|
#
|
96
|
-
# @param [Western::Calendar]
|
55
|
+
# @param [Western::Calendar] start_date 開始日
|
56
|
+
# @param [Western::Calendar] last_date 終了日
|
97
57
|
#
|
98
|
-
# @return [
|
58
|
+
# @return [Array<LinearGengou>] 2行目元号
|
99
59
|
#
|
100
|
-
def self.second_line(
|
101
|
-
|
102
|
-
|
60
|
+
def self.second_line(start_date: Western::Calendar.new, last_date: Western::Calendar.new)
|
61
|
+
Alignment.get(
|
62
|
+
line: SECOND_LINE, start_date: start_date, last_date: last_date
|
63
|
+
)
|
103
64
|
end
|
104
65
|
end
|
105
66
|
end
|
@@ -23,7 +23,7 @@ module Zakuro
|
|
23
23
|
# @return [Integer] 開始西暦年
|
24
24
|
attr_reader :start_year
|
25
25
|
# @return [Integer] 終了西暦年
|
26
|
-
attr_reader :
|
26
|
+
attr_reader :last_year
|
27
27
|
# @return [True] リリース済
|
28
28
|
# @return [False] 未リリース
|
29
29
|
attr_reader :released
|
@@ -34,20 +34,20 @@ module Zakuro
|
|
34
34
|
# @param [String] name 暦名
|
35
35
|
# @param [Western::Calendar] start_date 暦の開始日
|
36
36
|
# @param [Integer] start_year 開始西暦年
|
37
|
-
# @param [Integer]
|
37
|
+
# @param [Integer] last_year 終了西暦年
|
38
38
|
# @param [True, False] released リリース済 / 未リリース
|
39
39
|
#
|
40
|
-
def initialize(name:, start_date:, start_year:,
|
40
|
+
def initialize(name:, start_date:, start_year:, last_year:, released:)
|
41
41
|
@name = name
|
42
42
|
@start_date = start_date
|
43
43
|
@start_year = start_year
|
44
|
-
@
|
44
|
+
@last_year = last_year
|
45
45
|
@released = released
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
# TODO: yamlにする
|
50
|
-
# TODO:
|
50
|
+
# TODO: last_year は不要
|
51
51
|
|
52
52
|
# @return [Array<Range>] 全和暦
|
53
53
|
LIST = [
|
@@ -56,7 +56,7 @@ module Zakuro
|
|
56
56
|
name: 'Genka',
|
57
57
|
start_date: Western::Calendar.new(year: 445, month: 1, day: 24),
|
58
58
|
start_year: 445,
|
59
|
-
|
59
|
+
last_year: 697,
|
60
60
|
released: true
|
61
61
|
),
|
62
62
|
# 文武天皇02年01月01日
|
@@ -64,7 +64,7 @@ module Zakuro
|
|
64
64
|
name: 'Gihou',
|
65
65
|
start_date: Western::Calendar.new(year: 698, month: 2, day: 16),
|
66
66
|
start_year: 698,
|
67
|
-
|
67
|
+
last_year: 763,
|
68
68
|
released: true
|
69
69
|
),
|
70
70
|
# 天平宝字08年01月01日
|
@@ -72,7 +72,7 @@ module Zakuro
|
|
72
72
|
name: 'Daien',
|
73
73
|
start_date: Western::Calendar.new(year: 764, month: 2, day: 7),
|
74
74
|
start_year: 764,
|
75
|
-
|
75
|
+
last_year: 861,
|
76
76
|
released: true
|
77
77
|
),
|
78
78
|
# 貞観02年01月01日
|
@@ -80,7 +80,7 @@ module Zakuro
|
|
80
80
|
name: 'Senmyou',
|
81
81
|
start_date: Western::Calendar.new(year: 862, month: 2, day: 3),
|
82
82
|
start_year: 862,
|
83
|
-
|
83
|
+
last_year: 1684,
|
84
84
|
released: true
|
85
85
|
),
|
86
86
|
# 貞享02年01月01日
|
@@ -88,7 +88,7 @@ module Zakuro
|
|
88
88
|
name: 'Joukyou',
|
89
89
|
start_date: Western::Calendar.new(year: 1685, month: 2, day: 4),
|
90
90
|
start_year: 1685,
|
91
|
-
|
91
|
+
last_year: 1754,
|
92
92
|
released: false
|
93
93
|
),
|
94
94
|
# 宝暦05年01月01日
|
@@ -96,7 +96,7 @@ module Zakuro
|
|
96
96
|
name: 'Houryaku',
|
97
97
|
start_date: Western::Calendar.new(year: 1755, month: 2, day: 11),
|
98
98
|
start_year: 1755,
|
99
|
-
|
99
|
+
last_year: 1797,
|
100
100
|
released: false
|
101
101
|
),
|
102
102
|
# 寛政10年01月01日
|
@@ -104,7 +104,7 @@ module Zakuro
|
|
104
104
|
name: 'Kansei',
|
105
105
|
start_date: Western::Calendar.new(year: 1798, month: 2, day: 16),
|
106
106
|
start_year: 1798,
|
107
|
-
|
107
|
+
last_year: 1843,
|
108
108
|
released: false
|
109
109
|
),
|
110
110
|
# 天保13年01月01日
|
@@ -112,7 +112,7 @@ module Zakuro
|
|
112
112
|
name: 'Tenpou',
|
113
113
|
start_date: Western::Calendar.new(year: 1844, month: 2, day: 18),
|
114
114
|
start_year: 1844,
|
115
|
-
|
115
|
+
last_year: 1867,
|
116
116
|
released: false
|
117
117
|
),
|
118
118
|
# 明治01年09月08日
|
@@ -120,7 +120,7 @@ module Zakuro
|
|
120
120
|
name: 'Gregorio',
|
121
121
|
start_date: Western::Calendar.new(year: 1868, month: 10, day: 23),
|
122
122
|
start_year: 1868,
|
123
|
-
|
123
|
+
last_year: 9999,
|
124
124
|
released: false
|
125
125
|
)
|
126
126
|
].freeze
|
@@ -129,17 +129,17 @@ module Zakuro
|
|
129
129
|
# 年を基準に暦を引き当てる
|
130
130
|
#
|
131
131
|
# @param [Integer] start_year 開始西暦年
|
132
|
-
# @param [Integer]
|
132
|
+
# @param [Integer] last_year 終了西暦年
|
133
133
|
#
|
134
134
|
# @return [Array<Range>] 和暦
|
135
135
|
#
|
136
|
-
def self.ranges_with_year(start_year:,
|
136
|
+
def self.ranges_with_year(start_year:, last_year:)
|
137
137
|
result = []
|
138
138
|
|
139
139
|
LIST.each do |range|
|
140
|
-
next if start_year > range.
|
140
|
+
next if start_year > range.last_year
|
141
141
|
|
142
|
-
next if
|
142
|
+
next if last_year < range.start_year
|
143
143
|
|
144
144
|
result.push(range)
|
145
145
|
end
|
data/lib/zakuro/merchant.rb
CHANGED
@@ -4,6 +4,8 @@ require_relative './era/western/calendar'
|
|
4
4
|
|
5
5
|
require_relative './calculation/summary/single'
|
6
6
|
|
7
|
+
require_relative './calculation/summary/range'
|
8
|
+
|
7
9
|
require_relative './condition'
|
8
10
|
|
9
11
|
require_relative './output/error'
|
@@ -50,19 +52,55 @@ module Zakuro
|
|
50
52
|
# 承諾する
|
51
53
|
#
|
52
54
|
# @return [Result::SingleDay] 和暦日
|
55
|
+
# @return [Result::Range] 和暦日範囲
|
53
56
|
#
|
54
57
|
def commit
|
55
58
|
date = condition.date
|
56
59
|
|
57
|
-
|
58
|
-
|
60
|
+
return single(date: date) if date
|
61
|
+
|
62
|
+
range = condition.range
|
63
|
+
|
64
|
+
return range(range: range) if range
|
65
|
+
|
66
|
+
{}
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
59
70
|
|
71
|
+
#
|
72
|
+
# 1日検索
|
73
|
+
#
|
74
|
+
# @param [Date] date 西暦日
|
75
|
+
#
|
76
|
+
# @return [Result::Single] 検索結果
|
77
|
+
#
|
78
|
+
def single(date:)
|
60
79
|
western_date = Western::Calendar.create(date: date)
|
61
80
|
|
62
|
-
# TODO:
|
81
|
+
# TODO: condition で設定する
|
63
82
|
context = Context.new(version_name: '')
|
64
83
|
|
65
84
|
Calculation::Summary::Single.get(context: context, date: western_date)
|
66
85
|
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# 期間検索
|
89
|
+
#
|
90
|
+
# @param [Catalog::Range] range 期間
|
91
|
+
#
|
92
|
+
# @return [Result::Range] 和暦日範囲
|
93
|
+
#
|
94
|
+
def range(range:)
|
95
|
+
start_date = Western::Calendar.create(date: range[:start])
|
96
|
+
last_date = Western::Calendar.create(date: range[:last])
|
97
|
+
|
98
|
+
# TODO: condition で設定する
|
99
|
+
context = Context.new(version_name: '')
|
100
|
+
|
101
|
+
Calculation::Summary::Range.get(
|
102
|
+
context: context, start_date: start_date, last_date: last_date
|
103
|
+
)
|
104
|
+
end
|
67
105
|
end
|
68
106
|
end
|
data/lib/zakuro/result/result.rb
CHANGED
@@ -33,5 +33,22 @@ module Zakuro
|
|
33
33
|
@operation = operation
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Range 期間検索結果
|
39
|
+
#
|
40
|
+
class Range < Core
|
41
|
+
attr_reader :list
|
42
|
+
|
43
|
+
#
|
44
|
+
# 初期化
|
45
|
+
#
|
46
|
+
# @param [Array<Data::Single>] list 期間内データ
|
47
|
+
#
|
48
|
+
def initialize(list: [])
|
49
|
+
super
|
50
|
+
@list = list
|
51
|
+
end
|
52
|
+
end
|
36
53
|
end
|
37
54
|
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
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zakuro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pldb
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: mainly lunar solar calendar
|
14
14
|
email:
|
@@ -48,11 +48,16 @@ files:
|
|
48
48
|
- lib/zakuro/calculation/cycle/abstract_remainder.rb
|
49
49
|
- lib/zakuro/calculation/cycle/abstract_solar_term.rb
|
50
50
|
- lib/zakuro/calculation/cycle/zodiac.rb
|
51
|
-
- lib/zakuro/calculation/gengou/internal/
|
52
|
-
- lib/zakuro/calculation/gengou/internal/
|
53
|
-
- lib/zakuro/calculation/gengou/internal/
|
54
|
-
- lib/zakuro/calculation/gengou/internal/reserve
|
55
|
-
- lib/zakuro/calculation/gengou/
|
51
|
+
- lib/zakuro/calculation/era/gengou/internal/connector.rb
|
52
|
+
- lib/zakuro/calculation/era/gengou/internal/counter.rb
|
53
|
+
- lib/zakuro/calculation/era/gengou/internal/publisher.rb
|
54
|
+
- lib/zakuro/calculation/era/gengou/internal/reserve.rb
|
55
|
+
- lib/zakuro/calculation/era/gengou/internal/reserve/list.rb
|
56
|
+
- lib/zakuro/calculation/era/gengou/internal/reserve/range.rb
|
57
|
+
- lib/zakuro/calculation/era/gengou/scroll.rb
|
58
|
+
- lib/zakuro/calculation/era/version/internal/crawler.rb
|
59
|
+
- lib/zakuro/calculation/era/version/internal/range.rb
|
60
|
+
- lib/zakuro/calculation/era/version/version.rb
|
56
61
|
- lib/zakuro/calculation/monthly/abstract_lunar_phase.rb
|
57
62
|
- lib/zakuro/calculation/monthly/first_day.rb
|
58
63
|
- lib/zakuro/calculation/monthly/initialized_month.rb
|
@@ -65,26 +70,33 @@ files:
|
|
65
70
|
- lib/zakuro/calculation/range/operated_solar_terms.rb
|
66
71
|
- lib/zakuro/calculation/range/transfer/gengou_scroller.rb
|
67
72
|
- lib/zakuro/calculation/range/transfer/year_boundary.rb
|
73
|
+
- lib/zakuro/calculation/specifier/internal/month.rb
|
74
|
+
- lib/zakuro/calculation/specifier/multiple_day.rb
|
68
75
|
- lib/zakuro/calculation/specifier/single_day.rb
|
69
76
|
- lib/zakuro/calculation/stella/lunar/abstract_location.rb
|
70
77
|
- lib/zakuro/calculation/stella/lunar/choukei_value.rb
|
71
78
|
- lib/zakuro/calculation/stella/solar/abstract_average.rb
|
72
79
|
- lib/zakuro/calculation/stella/solar/abstract_location.rb
|
73
80
|
- lib/zakuro/calculation/stella/solar/choukei_value.rb
|
81
|
+
- lib/zakuro/calculation/summary/internal/operation.rb
|
82
|
+
- lib/zakuro/calculation/summary/range.rb
|
74
83
|
- lib/zakuro/calculation/summary/single.rb
|
75
84
|
- lib/zakuro/calculation/type/old_float.rb
|
76
|
-
- lib/zakuro/calculation/version/internal/crawler.rb
|
77
|
-
- lib/zakuro/calculation/version/internal/range.rb
|
78
|
-
- lib/zakuro/calculation/version/version.rb
|
79
85
|
- lib/zakuro/condition.rb
|
80
86
|
- lib/zakuro/era/japan/calendar.rb
|
81
87
|
- lib/zakuro/era/japan/gengou.rb
|
82
|
-
- lib/zakuro/era/japan/gengou/
|
83
|
-
- lib/zakuro/era/japan/gengou/
|
84
|
-
- lib/zakuro/era/japan/gengou/
|
85
|
-
- lib/zakuro/era/japan/gengou/
|
86
|
-
- lib/zakuro/era/japan/gengou/
|
87
|
-
- lib/zakuro/era/japan/gengou/
|
88
|
+
- lib/zakuro/era/japan/gengou/alignment.rb
|
89
|
+
- lib/zakuro/era/japan/gengou/alignment/aligner.rb
|
90
|
+
- lib/zakuro/era/japan/gengou/alignment/division.rb
|
91
|
+
- lib/zakuro/era/japan/gengou/alignment/line.rb
|
92
|
+
- lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb
|
93
|
+
- lib/zakuro/era/japan/gengou/resource.rb
|
94
|
+
- lib/zakuro/era/japan/gengou/resource/parser.rb
|
95
|
+
- lib/zakuro/era/japan/gengou/resource/type.rb
|
96
|
+
- lib/zakuro/era/japan/gengou/resource/validator.rb
|
97
|
+
- lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml
|
98
|
+
- lib/zakuro/era/japan/gengou/resource/yaml/set-002-from-north.yaml
|
99
|
+
- lib/zakuro/era/japan/gengou/resource/yaml/set-003-modern.yaml
|
88
100
|
- lib/zakuro/era/japan/version.rb
|
89
101
|
- lib/zakuro/era/western/calendar.rb
|
90
102
|
- lib/zakuro/merchant.rb
|
@@ -187,7 +199,7 @@ metadata:
|
|
187
199
|
homepage_uri: https://github.com/pldb/zakuro
|
188
200
|
source_code_uri: https://github.com/pldb/zakuro
|
189
201
|
changelog_uri: https://github.com/pldb/zakuro
|
190
|
-
post_install_message:
|
202
|
+
post_install_message:
|
191
203
|
rdoc_options: []
|
192
204
|
require_paths:
|
193
205
|
- lib
|
@@ -202,8 +214,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
214
|
- !ruby/object:Gem::Version
|
203
215
|
version: '0'
|
204
216
|
requirements: []
|
205
|
-
rubygems_version: 3.1.
|
206
|
-
signing_key:
|
217
|
+
rubygems_version: 3.1.2
|
218
|
+
signing_key:
|
207
219
|
specification_version: 4
|
208
220
|
summary: japanese calendar library.
|
209
221
|
test_files: []
|
@@ -1,129 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../../era/japan/gengou'
|
4
|
-
require_relative '../../../era/japan/calendar'
|
5
|
-
require_relative '../../../era/western/calendar'
|
6
|
-
|
7
|
-
# :nodoc:
|
8
|
-
module Zakuro
|
9
|
-
# :nodoc:
|
10
|
-
module Calculation
|
11
|
-
# :nodoc:
|
12
|
-
module Gengou
|
13
|
-
#
|
14
|
-
# Counter 加算元号
|
15
|
-
#
|
16
|
-
class Counter
|
17
|
-
# @return [Integer] 不正値
|
18
|
-
INVALID_YEAR = -1
|
19
|
-
|
20
|
-
# @return [Japan::Gengou] 元号
|
21
|
-
attr_reader :gengou
|
22
|
-
# @return [Integer] 元号年
|
23
|
-
attr_reader :japan_year
|
24
|
-
# @return [Integer] 西暦年
|
25
|
-
attr_reader :western_year
|
26
|
-
|
27
|
-
#
|
28
|
-
# 初期化
|
29
|
-
#
|
30
|
-
# @param [Japan::Gengou] gengou 元号
|
31
|
-
#
|
32
|
-
def initialize(gengou: Japan::Gengou.new)
|
33
|
-
@gengou = gengou
|
34
|
-
@japan_year = gengou.both_start_year.japan
|
35
|
-
@western_year = gengou.both_start_year.western
|
36
|
-
end
|
37
|
-
|
38
|
-
#
|
39
|
-
# 和暦開始日を取得する
|
40
|
-
#
|
41
|
-
# @return [Japan::Calendar] 和暦開始日
|
42
|
-
#
|
43
|
-
def japan_start_date
|
44
|
-
return Japan::Calendar.new if @gengou.invalid?
|
45
|
-
|
46
|
-
@gengou.both_start_date.japan
|
47
|
-
end
|
48
|
-
|
49
|
-
#
|
50
|
-
# 西暦開始日を取得する
|
51
|
-
#
|
52
|
-
# @return [Western::Calendar] 西暦開始日
|
53
|
-
#
|
54
|
-
def western_start_date
|
55
|
-
return Western::Calendar.new if @gengou.invalid?
|
56
|
-
|
57
|
-
@gengou.both_start_date.western
|
58
|
-
end
|
59
|
-
|
60
|
-
#
|
61
|
-
# 西暦終了日を取得する
|
62
|
-
#
|
63
|
-
# @return [Western::Calendar] 西暦終了日
|
64
|
-
#
|
65
|
-
def western_end_date
|
66
|
-
return Western::Calendar.new if @gengou.invalid?
|
67
|
-
|
68
|
-
@gengou.end_date
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
# 次年にする
|
73
|
-
#
|
74
|
-
# @return [MultiGengou] 自身
|
75
|
-
#
|
76
|
-
def next_year
|
77
|
-
@japan_year += 1
|
78
|
-
@western_year += 1
|
79
|
-
|
80
|
-
self
|
81
|
-
end
|
82
|
-
|
83
|
-
#
|
84
|
-
# 元号名を取得する
|
85
|
-
#
|
86
|
-
# @return [String] 元号名
|
87
|
-
#
|
88
|
-
def name
|
89
|
-
return '' unless @gengou
|
90
|
-
|
91
|
-
@gengou.name
|
92
|
-
end
|
93
|
-
|
94
|
-
#
|
95
|
-
# 不正か
|
96
|
-
#
|
97
|
-
# @return [True] 不正
|
98
|
-
# @return [False] 不正なし
|
99
|
-
#
|
100
|
-
def invalid?
|
101
|
-
@gengou.invalid? || @japan_year == INVALID_YEAR || @western_year == INVALID_YEAR
|
102
|
-
end
|
103
|
-
|
104
|
-
#
|
105
|
-
# 指定した日が元号に含まれるか
|
106
|
-
#
|
107
|
-
# @param [Western::Calendar] date 日
|
108
|
-
#
|
109
|
-
# @return [True] 含まれる
|
110
|
-
# @return [False] 含まれない
|
111
|
-
#
|
112
|
-
def include?
|
113
|
-
@gengou.include?
|
114
|
-
end
|
115
|
-
|
116
|
-
#
|
117
|
-
# ディープコピー
|
118
|
-
#
|
119
|
-
# @param [MultiGengou] obj 自身
|
120
|
-
#
|
121
|
-
def initialize_copy(obj)
|
122
|
-
@gengou = obj.gengou.clone
|
123
|
-
@japan_year = obj.japan_year
|
124
|
-
@western_year = obj.western_year
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|