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
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
id: 3
|
3
|
+
name: 近代(一世一元)
|
4
|
+
end_year:
|
5
|
+
japan: 7981
|
6
|
+
western: 9999
|
7
|
+
end_date:
|
8
|
+
japan: 令和7981年12月31日
|
9
|
+
western: '9999-12-31'
|
10
|
+
list:
|
11
|
+
- name: 明治
|
12
|
+
start_year:
|
13
|
+
japan: 1
|
14
|
+
western: 1868
|
15
|
+
start_date:
|
16
|
+
japan: 明治01年09月08日
|
17
|
+
western: '1868-10-23'
|
18
|
+
disuse:
|
19
|
+
new_year_date: '1868-1-25'
|
20
|
+
note: ''
|
21
|
+
- name: 大正
|
22
|
+
start_year:
|
23
|
+
japan: 1
|
24
|
+
western: 1912
|
25
|
+
start_date:
|
26
|
+
japan: 大正01年07月30日
|
27
|
+
western: '1912-7-30'
|
28
|
+
disuse:
|
29
|
+
new_year_date: '1912-1-1'
|
30
|
+
note: ''
|
31
|
+
- name: 昭和
|
32
|
+
start_year:
|
33
|
+
japan: 1
|
34
|
+
western: 1926
|
35
|
+
start_date:
|
36
|
+
japan: 昭和01年12月25日
|
37
|
+
western: '1926-12-25'
|
38
|
+
disuse:
|
39
|
+
new_year_date: '1926-1-1'
|
40
|
+
note: ''
|
41
|
+
- name: 令和
|
42
|
+
start_year:
|
43
|
+
japan: 1
|
44
|
+
western: 2019
|
45
|
+
start_date:
|
46
|
+
japan: 令和01年05月01日
|
47
|
+
western: '2019-5-1'
|
48
|
+
disuse:
|
49
|
+
new_year_date: '2019-1-1'
|
50
|
+
note: ''
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../western'
|
3
|
+
require_relative '../western/calendar'
|
4
4
|
require_relative './gengou/parser'
|
5
5
|
require_relative './gengou/type'
|
6
6
|
|
@@ -17,15 +17,15 @@ module Zakuro
|
|
17
17
|
# @return [Array<Set>] 元号セット情報リスト
|
18
18
|
LIST = [
|
19
19
|
Parser.run(filepath: File.expand_path(
|
20
|
-
'./yaml/set-001-until-south.yaml',
|
20
|
+
'./gengou/yaml/set-001-until-south.yaml',
|
21
21
|
__dir__
|
22
22
|
)),
|
23
23
|
Parser.run(filepath: File.expand_path(
|
24
|
-
'./yaml/set-002-from-north.yaml',
|
24
|
+
'./gengou/yaml/set-002-from-north.yaml',
|
25
25
|
__dir__
|
26
26
|
)),
|
27
27
|
Parser.run(filepath: File.expand_path(
|
28
|
-
'./yaml/set-003-modern.yaml',
|
28
|
+
'./gengou/yaml/set-003-modern.yaml',
|
29
29
|
__dir__
|
30
30
|
))
|
31
31
|
].freeze
|
@@ -35,7 +35,7 @@ module Zakuro
|
|
35
35
|
#
|
36
36
|
# 元号(1行目,2行目)を引き当てる
|
37
37
|
#
|
38
|
-
# *
|
38
|
+
# * LIST配列の元号情報を配列順で「x行目」(1始まり)とする
|
39
39
|
# * 1行目にデータがあれば、第一要素に1行目のデータが設定される
|
40
40
|
# * 1行目と2行目にデータがあれば、第二要素に2行目のデータが設定される
|
41
41
|
# * 1行目にデータがなく、2行目以降に1つだけデータがあれば、第一要素にそのデータを設定してそれ以外の要素は未設定
|
@@ -0,0 +1,151 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../western/calendar'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
#
|
8
|
+
# Japan 和暦
|
9
|
+
#
|
10
|
+
module Japan
|
11
|
+
#
|
12
|
+
# Version 暦
|
13
|
+
#
|
14
|
+
module Version
|
15
|
+
#
|
16
|
+
# Range 暦(範囲)
|
17
|
+
#
|
18
|
+
class Range
|
19
|
+
# @return [String] 暦名
|
20
|
+
attr_reader :name
|
21
|
+
# @return [Western::Calendar] 暦の開始日
|
22
|
+
attr_reader :start_date
|
23
|
+
# @return [Integer] 開始西暦年
|
24
|
+
attr_reader :start_year
|
25
|
+
# @return [Integer] 終了西暦年
|
26
|
+
attr_reader :end_year
|
27
|
+
# @return [True] リリース済
|
28
|
+
# @return [False] 未リリース
|
29
|
+
attr_reader :released
|
30
|
+
|
31
|
+
#
|
32
|
+
# 初期化
|
33
|
+
#
|
34
|
+
# @param [String] name 暦名
|
35
|
+
# @param [Western::Calendar] start_date 暦の開始日
|
36
|
+
# @param [Integer] start_year 開始西暦年
|
37
|
+
# @param [Integer] end_year 終了西暦年
|
38
|
+
# @param [True, False] released リリース済 / 未リリース
|
39
|
+
#
|
40
|
+
def initialize(name:, start_date:, start_year:, end_year:, released:)
|
41
|
+
@name = name
|
42
|
+
@start_date = start_date
|
43
|
+
@start_year = start_year
|
44
|
+
@end_year = end_year
|
45
|
+
@released = released
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# TODO: yamlにする
|
50
|
+
# TODO: end_year は不要
|
51
|
+
|
52
|
+
# @return [Array<Range>] 全和暦
|
53
|
+
LIST = [
|
54
|
+
# 允恭天皇34年01月01日
|
55
|
+
Range.new(
|
56
|
+
name: 'Genka',
|
57
|
+
start_date: Western::Calendar.new(year: 445, month: 1, day: 24),
|
58
|
+
start_year: 445,
|
59
|
+
end_year: 697,
|
60
|
+
released: true
|
61
|
+
),
|
62
|
+
# 文武天皇02年01月01日
|
63
|
+
Range.new(
|
64
|
+
name: 'Gihou',
|
65
|
+
start_date: Western::Calendar.new(year: 698, month: 2, day: 16),
|
66
|
+
start_year: 698,
|
67
|
+
end_year: 763,
|
68
|
+
released: true
|
69
|
+
),
|
70
|
+
# 天平宝字08年01月01日
|
71
|
+
Range.new(
|
72
|
+
name: 'Daien',
|
73
|
+
start_date: Western::Calendar.new(year: 764, month: 2, day: 7),
|
74
|
+
start_year: 764,
|
75
|
+
end_year: 861,
|
76
|
+
released: true
|
77
|
+
),
|
78
|
+
# 貞観02年01月01日
|
79
|
+
Range.new(
|
80
|
+
name: 'Senmyou',
|
81
|
+
start_date: Western::Calendar.new(year: 862, month: 2, day: 3),
|
82
|
+
start_year: 862,
|
83
|
+
end_year: 1684,
|
84
|
+
released: true
|
85
|
+
),
|
86
|
+
# 貞享02年01月01日
|
87
|
+
Range.new(
|
88
|
+
name: 'Joukyou',
|
89
|
+
start_date: Western::Calendar.new(year: 1685, month: 2, day: 4),
|
90
|
+
start_year: 1685,
|
91
|
+
end_year: 1754,
|
92
|
+
released: false
|
93
|
+
),
|
94
|
+
# 宝暦05年01月01日
|
95
|
+
Range.new(
|
96
|
+
name: 'Houryaku',
|
97
|
+
start_date: Western::Calendar.new(year: 1755, month: 2, day: 11),
|
98
|
+
start_year: 1755,
|
99
|
+
end_year: 1797,
|
100
|
+
released: false
|
101
|
+
),
|
102
|
+
# 寛政10年01月01日
|
103
|
+
Range.new(
|
104
|
+
name: 'Kansei',
|
105
|
+
start_date: Western::Calendar.new(year: 1798, month: 2, day: 16),
|
106
|
+
start_year: 1798,
|
107
|
+
end_year: 1843,
|
108
|
+
released: false
|
109
|
+
),
|
110
|
+
# 天保13年01月01日
|
111
|
+
Range.new(
|
112
|
+
name: 'Tenpou',
|
113
|
+
start_date: Western::Calendar.new(year: 1844, month: 2, day: 18),
|
114
|
+
start_year: 1844,
|
115
|
+
end_year: 1867,
|
116
|
+
released: false
|
117
|
+
),
|
118
|
+
# 明治01年09月08日
|
119
|
+
Range.new(
|
120
|
+
name: 'Gregorio',
|
121
|
+
start_date: Western::Calendar.new(year: 1868, month: 10, day: 23),
|
122
|
+
start_year: 1868,
|
123
|
+
end_year: 9999,
|
124
|
+
released: false
|
125
|
+
)
|
126
|
+
].freeze
|
127
|
+
|
128
|
+
#
|
129
|
+
# 年を基準に暦を引き当てる
|
130
|
+
#
|
131
|
+
# @param [Integer] start_year 開始西暦年
|
132
|
+
# @param [Integer] end_year 終了西暦年
|
133
|
+
#
|
134
|
+
# @return [Array<Range>] 和暦
|
135
|
+
#
|
136
|
+
def self.ranges_with_year(start_year:, end_year:)
|
137
|
+
result = []
|
138
|
+
|
139
|
+
LIST.each do |range|
|
140
|
+
next if start_year > range.end_year
|
141
|
+
|
142
|
+
next if end_year < range.start_year
|
143
|
+
|
144
|
+
result.push(range)
|
145
|
+
end
|
146
|
+
|
147
|
+
result
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
File without changes
|
data/lib/zakuro/merchant.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative './
|
3
|
+
require_relative './era/western/calendar'
|
4
|
+
|
5
|
+
require_relative './calculation/summary/single'
|
6
|
+
|
4
7
|
require_relative './condition'
|
5
8
|
|
6
9
|
require_relative './output/error'
|
@@ -50,10 +53,16 @@ module Zakuro
|
|
50
53
|
#
|
51
54
|
def commit
|
52
55
|
date = condition.date
|
53
|
-
return VersionFactory.to_japan_date(western_date: date) if date
|
54
56
|
|
55
57
|
# TODO: does not have no patterns now
|
56
|
-
{}
|
58
|
+
return {} unless date
|
59
|
+
|
60
|
+
western_date = Western::Calendar.create(date: date)
|
61
|
+
|
62
|
+
# TODO: 引数不要
|
63
|
+
context = Context.new(version_name: '')
|
64
|
+
|
65
|
+
Calculation::Summary::Single.get(context: context, date: western_date)
|
57
66
|
end
|
58
67
|
end
|
59
68
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yaml'
|
4
|
-
require_relative '../../era/western'
|
4
|
+
require_relative '../../era/western/calendar'
|
5
5
|
require_relative './validator'
|
6
6
|
|
7
7
|
# :nodoc:
|
@@ -364,6 +364,64 @@ module Zakuro
|
|
364
364
|
def invalid?
|
365
365
|
@calc == -1 || @actual == -1
|
366
366
|
end
|
367
|
+
|
368
|
+
#
|
369
|
+
# 無効か
|
370
|
+
#
|
371
|
+
# @return [True] 無効
|
372
|
+
# @return [False] 有効
|
373
|
+
#
|
374
|
+
def valid?
|
375
|
+
!invalid?
|
376
|
+
end
|
377
|
+
|
378
|
+
#
|
379
|
+
# 差分の間隔
|
380
|
+
#
|
381
|
+
# @return [Integer] 間隔
|
382
|
+
#
|
383
|
+
def interval
|
384
|
+
@calc - @actual
|
385
|
+
end
|
386
|
+
|
387
|
+
#
|
388
|
+
# 年変化するか
|
389
|
+
#
|
390
|
+
# @return [True] 変化あり
|
391
|
+
# @return [False] 変化なし
|
392
|
+
#
|
393
|
+
def change_year?
|
394
|
+
return false unless valid?
|
395
|
+
|
396
|
+
# 1年分の変化(12ヶ月以上)なしと見なす
|
397
|
+
return false if interval.abs < 11
|
398
|
+
|
399
|
+
true
|
400
|
+
end
|
401
|
+
|
402
|
+
#
|
403
|
+
# 昨年の月か
|
404
|
+
#
|
405
|
+
# @return [True] 昨年
|
406
|
+
# @return [False] 昨年ではない
|
407
|
+
#
|
408
|
+
def last_year?
|
409
|
+
return false unless change_year?
|
410
|
+
|
411
|
+
interval.negative?
|
412
|
+
end
|
413
|
+
|
414
|
+
#
|
415
|
+
# 来年の月か
|
416
|
+
#
|
417
|
+
# @return [True] 来年
|
418
|
+
# @return [False] 来年ではない
|
419
|
+
#
|
420
|
+
def next_year?
|
421
|
+
return false unless change_year?
|
422
|
+
|
423
|
+
interval.positive?
|
424
|
+
end
|
367
425
|
end
|
368
426
|
|
369
427
|
#
|