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
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.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pldb
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: mainly lunar solar calendar
|
14
14
|
email:
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- Makefile
|
27
27
|
- README.md
|
28
28
|
- Rakefile
|
29
|
+
- VERSION
|
29
30
|
- bin/console
|
30
31
|
- bin/setup
|
31
32
|
- doc/gengou.md
|
@@ -40,12 +41,18 @@ files:
|
|
40
41
|
- images/各月の求め方.png
|
41
42
|
- images/太陽と月.png
|
42
43
|
- lib/zakuro.rb
|
43
|
-
- lib/zakuro/calculation/base/
|
44
|
-
- lib/zakuro/calculation/base/
|
44
|
+
- lib/zakuro/calculation/base/gengou.rb
|
45
|
+
- lib/zakuro/calculation/base/linear_gengou.rb
|
46
|
+
- lib/zakuro/calculation/base/operated_year.rb
|
45
47
|
- lib/zakuro/calculation/base/year.rb
|
46
48
|
- lib/zakuro/calculation/cycle/abstract_remainder.rb
|
47
49
|
- lib/zakuro/calculation/cycle/abstract_solar_term.rb
|
48
50
|
- lib/zakuro/calculation/cycle/zodiac.rb
|
51
|
+
- lib/zakuro/calculation/gengou/internal/counter.rb
|
52
|
+
- lib/zakuro/calculation/gengou/internal/reserve.rb
|
53
|
+
- lib/zakuro/calculation/gengou/internal/reserve/interval.rb
|
54
|
+
- lib/zakuro/calculation/gengou/internal/reserve/list.rb
|
55
|
+
- lib/zakuro/calculation/gengou/scroll.rb
|
49
56
|
- lib/zakuro/calculation/monthly/abstract_lunar_phase.rb
|
50
57
|
- lib/zakuro/calculation/monthly/first_day.rb
|
51
58
|
- lib/zakuro/calculation/monthly/initialized_month.rb
|
@@ -56,7 +63,7 @@ files:
|
|
56
63
|
- lib/zakuro/calculation/range/medieval_annual_range.rb
|
57
64
|
- lib/zakuro/calculation/range/operated_range.rb
|
58
65
|
- lib/zakuro/calculation/range/operated_solar_terms.rb
|
59
|
-
- lib/zakuro/calculation/range/transfer/
|
66
|
+
- lib/zakuro/calculation/range/transfer/gengou_scroller.rb
|
60
67
|
- lib/zakuro/calculation/range/transfer/year_boundary.rb
|
61
68
|
- lib/zakuro/calculation/specifier/single_day.rb
|
62
69
|
- lib/zakuro/calculation/stella/lunar/abstract_location.rb
|
@@ -66,16 +73,20 @@ files:
|
|
66
73
|
- lib/zakuro/calculation/stella/solar/choukei_value.rb
|
67
74
|
- lib/zakuro/calculation/summary/single.rb
|
68
75
|
- 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
|
69
79
|
- lib/zakuro/condition.rb
|
80
|
+
- lib/zakuro/era/japan/calendar.rb
|
70
81
|
- lib/zakuro/era/japan/gengou.rb
|
71
82
|
- lib/zakuro/era/japan/gengou/parser.rb
|
72
83
|
- lib/zakuro/era/japan/gengou/type.rb
|
73
84
|
- lib/zakuro/era/japan/gengou/validator.rb
|
74
|
-
- lib/zakuro/era/japan/
|
75
|
-
- lib/zakuro/era/japan/yaml/set-
|
76
|
-
- lib/zakuro/era/japan/yaml/set-
|
77
|
-
- lib/zakuro/era/japan/
|
78
|
-
- lib/zakuro/era/western.rb
|
85
|
+
- lib/zakuro/era/japan/gengou/yaml/set-001-until-south.yaml
|
86
|
+
- lib/zakuro/era/japan/gengou/yaml/set-002-from-north.yaml
|
87
|
+
- lib/zakuro/era/japan/gengou/yaml/set-003-modern.yaml
|
88
|
+
- lib/zakuro/era/japan/version.rb
|
89
|
+
- lib/zakuro/era/western/calendar.rb
|
79
90
|
- lib/zakuro/merchant.rb
|
80
91
|
- lib/zakuro/operation/month/parser.rb
|
81
92
|
- lib/zakuro/operation/month/type.rb
|
@@ -90,11 +101,38 @@ files:
|
|
90
101
|
- lib/zakuro/result/operation.rb
|
91
102
|
- lib/zakuro/result/result.rb
|
92
103
|
- lib/zakuro/tools/stringifier.rb
|
104
|
+
- lib/zakuro/tools/typeconv.rb
|
93
105
|
- lib/zakuro/tools/typeof.rb
|
94
|
-
- lib/zakuro/version.rb
|
95
|
-
- lib/zakuro/version/abstract_version.rb
|
96
106
|
- lib/zakuro/version/context.rb
|
107
|
+
- lib/zakuro/version/daien/const/number.rb
|
108
|
+
- lib/zakuro/version/daien/const/remainder.rb
|
109
|
+
- lib/zakuro/version/daien/cycle/remainder.rb
|
110
|
+
- lib/zakuro/version/daien/cycle/solar_term.rb
|
111
|
+
- lib/zakuro/version/daien/daien.rb
|
112
|
+
- lib/zakuro/version/daien/monthly/lunar_phase.rb
|
113
|
+
- lib/zakuro/version/daien/range/annual_range.rb
|
114
|
+
- lib/zakuro/version/daien/stella/lunar/adjustment.rb
|
115
|
+
- lib/zakuro/version/daien/stella/lunar/localization.rb
|
116
|
+
- lib/zakuro/version/daien/stella/lunar/location.rb
|
117
|
+
- lib/zakuro/version/daien/stella/lunar/value.rb
|
118
|
+
- lib/zakuro/version/daien/stella/origin/average_november.rb
|
119
|
+
- lib/zakuro/version/daien/stella/origin/lunar_age.rb
|
120
|
+
- lib/zakuro/version/daien/stella/origin/winter_solstice.rb
|
121
|
+
- lib/zakuro/version/daien/stella/solar/adjustment.rb
|
122
|
+
- lib/zakuro/version/daien/stella/solar/average.rb
|
123
|
+
- lib/zakuro/version/daien/stella/solar/interval.rb
|
124
|
+
- lib/zakuro/version/daien/stella/solar/location.rb
|
125
|
+
- lib/zakuro/version/daien/stella/solar/value.rb
|
126
|
+
- lib/zakuro/version/genka/const/number.rb
|
127
|
+
- lib/zakuro/version/genka/const/remainder.rb
|
128
|
+
- lib/zakuro/version/genka/cycle/remainder.rb
|
129
|
+
- lib/zakuro/version/genka/cycle/solar_term.rb
|
97
130
|
- lib/zakuro/version/genka/genka.rb
|
131
|
+
- lib/zakuro/version/genka/monthly/lunar_phase.rb
|
132
|
+
- lib/zakuro/version/genka/range/annual_range.rb
|
133
|
+
- lib/zakuro/version/genka/stella/origin/first_term.rb
|
134
|
+
- lib/zakuro/version/genka/stella/origin/january.rb
|
135
|
+
- lib/zakuro/version/genka/stella/solar/average.rb
|
98
136
|
- lib/zakuro/version/gihou/const/number.rb
|
99
137
|
- lib/zakuro/version/gihou/const/remainder.rb
|
100
138
|
- lib/zakuro/version/gihou/cycle/remainder.rb
|
@@ -138,10 +176,8 @@ files:
|
|
138
176
|
- lib/zakuro/version/senmyou/stella/solar/interval.rb
|
139
177
|
- lib/zakuro/version/senmyou/stella/solar/location.rb
|
140
178
|
- lib/zakuro/version/senmyou/stella/solar/value.rb
|
141
|
-
- lib/zakuro/version/taien/taien.rb
|
142
179
|
- lib/zakuro/version/tenpou/tenpou.rb
|
143
180
|
- lib/zakuro/version/version_class_resolver.rb
|
144
|
-
- lib/zakuro/version_factory.rb
|
145
181
|
- zakuro.gemspec
|
146
182
|
homepage: https://github.com/pldb/zakuro
|
147
183
|
licenses:
|
@@ -1,101 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../era/japan/gengou'
|
4
|
-
require_relative '../../era/western'
|
5
|
-
|
6
|
-
# :nodoc:
|
7
|
-
module Zakuro
|
8
|
-
# :nodoc:
|
9
|
-
module Calculation
|
10
|
-
# :nodoc:
|
11
|
-
module Base
|
12
|
-
#
|
13
|
-
# MultiGengou 複数元号
|
14
|
-
#
|
15
|
-
class MultiGengou
|
16
|
-
# @return [Japan::Gengou] 元号(1行目)
|
17
|
-
attr_reader :first_line
|
18
|
-
# @return [Japan::Gengou] 元号(2行目)
|
19
|
-
attr_reader :second_line
|
20
|
-
# @return [Western::Calendar] 元旦
|
21
|
-
attr_reader :new_year_date
|
22
|
-
|
23
|
-
def initialize(first_line: Japan::Gengou.new, second_line: Japan::Gengou.new,
|
24
|
-
new_year_date: Western::Calendar.new)
|
25
|
-
@first_line = first_line
|
26
|
-
@second_line = second_line
|
27
|
-
@new_year_date = new_year_date
|
28
|
-
end
|
29
|
-
|
30
|
-
# :reek:TooManyStatements { max_statements: 7 }
|
31
|
-
|
32
|
-
#
|
33
|
-
# 改元する
|
34
|
-
#
|
35
|
-
# @param [Japan::Gengou] first_line 元号(1行目)
|
36
|
-
# @param [Japan::Gengou] second_line 元号(2行目)
|
37
|
-
#
|
38
|
-
# @return [MultiGengou] 自身
|
39
|
-
#
|
40
|
-
def transfer(first_line: Japan::Gengou.new, second_line: Japan::Gengou.new)
|
41
|
-
cloned_first_line = first_line.clone
|
42
|
-
cloned_second_line = second_line.clone
|
43
|
-
|
44
|
-
if integrated?(first_line: cloned_first_line, second_line: cloned_second_line)
|
45
|
-
@first_line = @second_line.clone
|
46
|
-
@second_line = cloned_second_line
|
47
|
-
end
|
48
|
-
|
49
|
-
@first_line = cloned_first_line if @first_line.name != first_line.name
|
50
|
-
@second_line = cloned_second_line if @second_line.name != second_line.name
|
51
|
-
|
52
|
-
self
|
53
|
-
end
|
54
|
-
|
55
|
-
#
|
56
|
-
# 次年にする
|
57
|
-
#
|
58
|
-
# @param [Japan::Gengou] first_line 元号(1行目)
|
59
|
-
# @param [Japan::Gengou] second_line 元号(2行目)
|
60
|
-
#
|
61
|
-
# @return [MultiGengou] 自身
|
62
|
-
#
|
63
|
-
def next_year
|
64
|
-
@first_line.next_year
|
65
|
-
@second_line.next_year
|
66
|
-
|
67
|
-
self
|
68
|
-
end
|
69
|
-
|
70
|
-
#
|
71
|
-
# ディープコピー
|
72
|
-
#
|
73
|
-
# @param [MultiGengou] obj 自身
|
74
|
-
#
|
75
|
-
def initialize_copy(obj)
|
76
|
-
@first_line = obj.first_line.clone
|
77
|
-
@second_line = obj.second_line.clone
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
#
|
83
|
-
# 複数元号を統一するかどうか
|
84
|
-
#
|
85
|
-
# @param [Japan::Gengou] first_line 元号(1行目)
|
86
|
-
# @param [Japan::Gengou] second_line 元号(2行目)
|
87
|
-
#
|
88
|
-
# @return [True] 統一する
|
89
|
-
# @return [False] 統一しない
|
90
|
-
#
|
91
|
-
def integrated?(first_line: Japan::Gengou.new, second_line: Japan::Gengou.new)
|
92
|
-
return false if @second_line.name != first_line.name
|
93
|
-
|
94
|
-
return false unless second_line.invalid?
|
95
|
-
|
96
|
-
true
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
@@ -1,218 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative './multi_gengou'
|
4
|
-
|
5
|
-
require_relative '../../era/japan/gengou'
|
6
|
-
|
7
|
-
# :nodoc:
|
8
|
-
module Zakuro
|
9
|
-
# :nodoc:
|
10
|
-
module Calculation
|
11
|
-
# :nodoc:
|
12
|
-
module Base
|
13
|
-
#
|
14
|
-
# MultiGengouRoller 改元処理
|
15
|
-
#
|
16
|
-
class MultiGengouRoller
|
17
|
-
# @return [MultiGengou] 複数元号
|
18
|
-
attr_reader :multi_gengou
|
19
|
-
# @return [Western::Calendar] 元旦(元号が2つある場合は再過去の日付になる)
|
20
|
-
attr_reader :oldest_date
|
21
|
-
# @return [Western::Calendar] 元号内での最未来日(元号が2つある場合は再未来の日付になる)
|
22
|
-
attr_reader :newest_date
|
23
|
-
# @return [Western::Calendar] 現在日
|
24
|
-
attr_reader :current_date
|
25
|
-
|
26
|
-
def initialize(start_date: Western::Calendar.new, end_date: Western::Calendar.new)
|
27
|
-
end_date = start_date if end_date.invalid?
|
28
|
-
|
29
|
-
@oldest_date = MultiGengouRoller.choise_oldest_gengou_date(
|
30
|
-
first_line: MultiGengouRoller.first_line(date: start_date),
|
31
|
-
second_line: MultiGengouRoller.second_line(date: start_date)
|
32
|
-
)
|
33
|
-
@current_date = @oldest_date.clone
|
34
|
-
@newest_date = MultiGengouRoller.choise_newest_gengou_date(
|
35
|
-
first_line: MultiGengouRoller.first_line(date: end_date),
|
36
|
-
second_line: MultiGengouRoller.second_line(date: end_date)
|
37
|
-
)
|
38
|
-
|
39
|
-
@multi_gengou = MultiGengou.new(
|
40
|
-
first_line: current_first_line,
|
41
|
-
second_line: current_second_line,
|
42
|
-
new_year_date: @oldest_date
|
43
|
-
)
|
44
|
-
end
|
45
|
-
|
46
|
-
#
|
47
|
-
# 現在日付を未来に進める
|
48
|
-
#
|
49
|
-
# @param [<Type>] days <description>
|
50
|
-
#
|
51
|
-
# @return [<Type>] <description>
|
52
|
-
#
|
53
|
-
def next(days: 0)
|
54
|
-
@current_date += days
|
55
|
-
end
|
56
|
-
|
57
|
-
#
|
58
|
-
# 現在日から元号(1行目)を取得する
|
59
|
-
#
|
60
|
-
# @return [Japan::Gengou] 元号(1行目)
|
61
|
-
#
|
62
|
-
def current_first_line
|
63
|
-
MultiGengouRoller.first_line(date: @current_date)
|
64
|
-
end
|
65
|
-
|
66
|
-
#
|
67
|
-
# 現在日から元号(2行目)を取得する
|
68
|
-
#
|
69
|
-
# @return [Japan::Gengou] 元号(2行目)
|
70
|
-
#
|
71
|
-
def current_second_line
|
72
|
-
MultiGengouRoller.second_line(date: @current_date)
|
73
|
-
end
|
74
|
-
|
75
|
-
#
|
76
|
-
# 改元する
|
77
|
-
#
|
78
|
-
# @return [MultiGengou] 複数元号
|
79
|
-
#
|
80
|
-
def transfer
|
81
|
-
MultiGengouRoller.transfer(multi_gengou: @multi_gengou, date: @current_date)
|
82
|
-
end
|
83
|
-
|
84
|
-
#
|
85
|
-
# 次年にする
|
86
|
-
#
|
87
|
-
# @return [MultiGengou] 複数元号
|
88
|
-
#
|
89
|
-
def next_year
|
90
|
-
@multi_gengou.next_year
|
91
|
-
end
|
92
|
-
|
93
|
-
#
|
94
|
-
# 元号(1行目)を取得する
|
95
|
-
#
|
96
|
-
# @return [Japan::Gengou] 元号(1行目)
|
97
|
-
#
|
98
|
-
def self.first_line(date: Western::Calender.new)
|
99
|
-
Japan::GengouResource.first_line(date: date)
|
100
|
-
end
|
101
|
-
|
102
|
-
#
|
103
|
-
# 元号(2行目)を取得する
|
104
|
-
#
|
105
|
-
# @return [Japan::Gengou] 元号(2行目)
|
106
|
-
#
|
107
|
-
def self.second_line(date: Western::Calender.new)
|
108
|
-
Japan::GengouResource.second_line(date: date)
|
109
|
-
end
|
110
|
-
|
111
|
-
#
|
112
|
-
# 改元する
|
113
|
-
#
|
114
|
-
# @param [MultiGengou] multi_gengou 複数元号
|
115
|
-
# @param [Western::Calendar] date 対象日
|
116
|
-
#
|
117
|
-
# @return [MultiGengou] 改元済み複数元号
|
118
|
-
#
|
119
|
-
def self.transfer(multi_gengou:, date:)
|
120
|
-
multi_gengou.transfer(
|
121
|
-
first_line: first_line(date: date),
|
122
|
-
second_line: second_line(date: date)
|
123
|
-
)
|
124
|
-
|
125
|
-
multi_gengou
|
126
|
-
end
|
127
|
-
|
128
|
-
#
|
129
|
-
# 現在日からみて直近の未来に対する元号の切替前日を求める
|
130
|
-
# @note 2つの元号が重複した場合はより過去の日となる
|
131
|
-
#
|
132
|
-
# @param [Japan::Gengou] first_line 元号(1行目)
|
133
|
-
# @param [Japan::Gengou] second_line 元号(2行目)
|
134
|
-
#
|
135
|
-
# @return [Western::Calendar] 元号の切替前日
|
136
|
-
#
|
137
|
-
def choise_nearest_end_date
|
138
|
-
condition = lambda do |first_date, second_date|
|
139
|
-
first_date < second_date ? first_date : second_date
|
140
|
-
end
|
141
|
-
|
142
|
-
second_line = current_second_line
|
143
|
-
|
144
|
-
MultiGengouRoller.choise_date(condition: condition, second_line: second_line,
|
145
|
-
first_date: current_first_line.end_date.clone,
|
146
|
-
second_date: second_line.end_date.clone)
|
147
|
-
end
|
148
|
-
|
149
|
-
#
|
150
|
-
# 最過去の元旦を求める
|
151
|
-
# @note 2つの元号が重複した場合はより過去の日となる
|
152
|
-
#
|
153
|
-
# @param [Japan::Gengou] first_line 元号(1行目)
|
154
|
-
# @param [Japan::Gengou] second_line 元号(2行目)
|
155
|
-
#
|
156
|
-
# @return [Western::Calendar] 最過去の元旦
|
157
|
-
#
|
158
|
-
def self.choise_oldest_gengou_date(first_line:, second_line:)
|
159
|
-
condition = lambda do |first_date, second_date|
|
160
|
-
first_date < second_date ? first_date : second_date
|
161
|
-
end
|
162
|
-
choise_date(condition: condition, second_line: second_line,
|
163
|
-
first_date: first_line.new_year_date.clone,
|
164
|
-
second_date: second_line.new_year_date.clone)
|
165
|
-
end
|
166
|
-
|
167
|
-
#
|
168
|
-
# 元号内での最未来日を求める
|
169
|
-
# @note 2つの元号が重複した場合はより未来の日となる
|
170
|
-
#
|
171
|
-
# @param [Japan::Gengou] first_line 元号(1行目)
|
172
|
-
# @param [Japan::Gengou] second_line 元号(2行目)
|
173
|
-
#
|
174
|
-
# @return [Western::Calendar] 最未来日
|
175
|
-
#
|
176
|
-
def self.choise_newest_gengou_date(first_line:, second_line:)
|
177
|
-
condition = lambda do |first_date, second_date|
|
178
|
-
first_date > second_date ? first_date : second_date
|
179
|
-
end
|
180
|
-
choise_date(condition: condition, second_line: second_line,
|
181
|
-
first_date: first_line.end_date.clone,
|
182
|
-
second_date: second_line.end_date.clone)
|
183
|
-
end
|
184
|
-
|
185
|
-
# :reek:LongParameterList {max_params: 4}
|
186
|
-
|
187
|
-
#
|
188
|
-
# 条件を元に日付を求める
|
189
|
-
#
|
190
|
-
# @param [Proc] condition 比較条件
|
191
|
-
# @param [Japan::Gengou] second_line 元号(2行目)
|
192
|
-
# @param [Western::Calendar] first_date 比較対象(1行目)
|
193
|
-
# @param [Western::Calendar] second_date 比較対象(2行目)
|
194
|
-
#
|
195
|
-
# @return [Western::Calendar] 比較結果
|
196
|
-
#
|
197
|
-
def self.choise_date(condition:, second_line:, first_date:, second_date:)
|
198
|
-
# first_lineは常に存在する
|
199
|
-
return first_date if second_line.invalid?
|
200
|
-
|
201
|
-
condition.call(first_date, second_date)
|
202
|
-
end
|
203
|
-
|
204
|
-
#
|
205
|
-
# ディープコピー
|
206
|
-
#
|
207
|
-
# @param [MultiGengou] obj 自身
|
208
|
-
#
|
209
|
-
def initialize_copy(obj)
|
210
|
-
@oldest_date = obj.oldest_date.clone
|
211
|
-
@current_date = obj.current_date.clone
|
212
|
-
@newest_date = obj.newest_date.clone
|
213
|
-
@multi_gengou = obj.multi_gengou.clone
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# :nodoc:
|
4
|
-
module Zakuro
|
5
|
-
# :nodoc:
|
6
|
-
module Calculation
|
7
|
-
# :nodoc:
|
8
|
-
module Range
|
9
|
-
# :nodoc:
|
10
|
-
module Transfer
|
11
|
-
#
|
12
|
-
# WesternDateAllocation 西暦日の割り当て
|
13
|
-
#
|
14
|
-
module WesternDateAllocation
|
15
|
-
#
|
16
|
-
# 月初日の西暦日を更新する
|
17
|
-
#
|
18
|
-
# @param [Context] context 暦コンテキスト
|
19
|
-
# @param [Array<Year>] years 完全範囲(月初日なし)
|
20
|
-
#
|
21
|
-
# @return [Array<Year>] 完全範囲(月初日あり)
|
22
|
-
#
|
23
|
-
def self.get(context:, years:)
|
24
|
-
update_first_day(context: context, years: years)
|
25
|
-
|
26
|
-
years
|
27
|
-
end
|
28
|
-
|
29
|
-
#
|
30
|
-
# 月初日の西暦日を更新する
|
31
|
-
#
|
32
|
-
# @param [Context] context 暦コンテキスト
|
33
|
-
# @param [Array<Year>] years 完全範囲(月初日なし)
|
34
|
-
#
|
35
|
-
def self.update_first_day(context:, years:)
|
36
|
-
years.each_with_index do |year, index|
|
37
|
-
new_year_date = year.new_year_date.clone
|
38
|
-
|
39
|
-
months = year.months
|
40
|
-
update_first_day_within_all_months(
|
41
|
-
context: context,
|
42
|
-
new_year_date: new_year_date, months: months
|
43
|
-
)
|
44
|
-
|
45
|
-
years[index] = Base::Year.new(
|
46
|
-
multi_gengou: year.multi_gengou, new_year_date: new_year_date,
|
47
|
-
months: months, total_days: year.total_days
|
48
|
-
)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
#
|
53
|
-
# 全ての月で月初日の西暦日を更新する
|
54
|
-
#
|
55
|
-
# @param [Context] context 暦コンテキスト
|
56
|
-
# @param [Western::Calendar] new_year_date 元旦
|
57
|
-
# @param [Array<Month>] months 月データ
|
58
|
-
#
|
59
|
-
def self.update_first_day_within_all_months(context:,
|
60
|
-
new_year_date:, months:)
|
61
|
-
date = new_year_date.clone
|
62
|
-
months.each_with_index do |month, index|
|
63
|
-
updated_month = Monthly::Month.new(
|
64
|
-
context: context,
|
65
|
-
month_label: month.month_label,
|
66
|
-
first_day: Monthly::FirstDay.new(
|
67
|
-
remainder: month.first_day.remainder,
|
68
|
-
western_date: date
|
69
|
-
),
|
70
|
-
solar_terms: month.solar_terms
|
71
|
-
)
|
72
|
-
months[index] = updated_month
|
73
|
-
|
74
|
-
date = date.clone + updated_month.days
|
75
|
-
end
|
76
|
-
end
|
77
|
-
private_class_method :update_first_day_within_all_months
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../western'
|
4
|
-
|
5
|
-
# :nodoc:
|
6
|
-
module Zakuro
|
7
|
-
#
|
8
|
-
# Japan 和暦
|
9
|
-
#
|
10
|
-
module Japan
|
11
|
-
#
|
12
|
-
# Reki 暦
|
13
|
-
#
|
14
|
-
module Reki
|
15
|
-
#
|
16
|
-
# Range 暦(範囲)
|
17
|
-
#
|
18
|
-
class Range
|
19
|
-
# @return [String] 暦のクラス名
|
20
|
-
# version 以下を参照
|
21
|
-
attr_reader :class_name
|
22
|
-
# @return [Western::Calendar] 暦の開始日
|
23
|
-
attr_reader :start_date
|
24
|
-
|
25
|
-
#
|
26
|
-
# 初期化
|
27
|
-
#
|
28
|
-
# @param [String] class_name 暦のクラス名
|
29
|
-
# @param [Western::Calendar] start_date 暦の開始日
|
30
|
-
#
|
31
|
-
def initialize(class_name:, start_date:)
|
32
|
-
@class_name = class_name
|
33
|
-
@start_date = start_date
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
LIST = [
|
38
|
-
Range.new(
|
39
|
-
class_name: 'Zakuro::Genka::Gateway',
|
40
|
-
start_date: Western::Calendar.new(year: 445, month: 1, day: 24)
|
41
|
-
),
|
42
|
-
Range.new(
|
43
|
-
class_name: 'Zakuro::Gihou::Gateway',
|
44
|
-
start_date: Western::Calendar.new(year: 698, month: 2, day: 16)
|
45
|
-
),
|
46
|
-
Range.new(
|
47
|
-
class_name: 'Zakuro::Taien::Gateway',
|
48
|
-
start_date: Western::Calendar.new(year: 764, month: 2, day: 7)
|
49
|
-
),
|
50
|
-
Range.new(
|
51
|
-
class_name: 'Zakuro::Senmyou::Gateway',
|
52
|
-
start_date: Western::Calendar.new(year: 862, month: 2, day: 3)
|
53
|
-
),
|
54
|
-
Range.new(
|
55
|
-
class_name: 'Zakuro::Joukyou::Gateway',
|
56
|
-
start_date: Western::Calendar.new(year: 1685, month: 2, day: 4)
|
57
|
-
),
|
58
|
-
Range.new(
|
59
|
-
class_name: 'Zakuro::Houryaku::Gateway',
|
60
|
-
start_date: Western::Calendar.new(year: 1755, month: 2, day: 11)
|
61
|
-
),
|
62
|
-
Range.new(
|
63
|
-
class_name: 'Zakuro::Kansei::Gateway',
|
64
|
-
start_date: Western::Calendar.new(year: 1798, month: 2, day: 16)
|
65
|
-
),
|
66
|
-
Range.new(
|
67
|
-
class_name: 'Zakuro::Tenpou::Gateway',
|
68
|
-
start_date: Western::Calendar.new(year: 1844, month: 2, day: 18)
|
69
|
-
),
|
70
|
-
Range.new(
|
71
|
-
class_name: 'Zakuro::Gregorio::Gateway',
|
72
|
-
start_date: Western::Calendar.new(year: 1872, month: 12, day: 9)
|
73
|
-
)
|
74
|
-
].freeze
|
75
|
-
|
76
|
-
#
|
77
|
-
# 指定した日付から対象の暦を引き当てる
|
78
|
-
#
|
79
|
-
# @param [Western::Calendar] date 日付
|
80
|
-
#
|
81
|
-
# @return [String] 暦のクラス名
|
82
|
-
#
|
83
|
-
def self.class_name(date: Western::Calendar.new)
|
84
|
-
LIST.reverse_each do |range|
|
85
|
-
return range.class_name if date >= range.start_date
|
86
|
-
end
|
87
|
-
raise ArgumentError, "invalid date: #{date.format}"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|