zakuro 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/doc/dropped_date.md +25 -0
- data/doc/operation/csv/month.csv +1 -1
- data/doc/operation/operation.xlsx +0 -0
- data/doc/vanished_date.md +26 -0
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +26 -0
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +1 -1
- data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +6 -2
- data/lib/zakuro/calculation/era/gengou/internal/counter.rb +5 -5
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +12 -5
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +9 -3
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +3 -2
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +4 -2
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +5 -3
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +9 -4
- data/lib/zakuro/calculation/era/gengou/named_scroll.rb +5 -2
- data/lib/zakuro/calculation/monthly/initialized_month.rb +4 -2
- data/lib/zakuro/calculation/monthly/meta/all_solar_term.rb +64 -0
- data/lib/zakuro/calculation/monthly/meta/meta_collector.rb +80 -0
- data/lib/zakuro/calculation/monthly/meta.rb +60 -0
- data/lib/zakuro/calculation/monthly/month.rb +60 -5
- data/lib/zakuro/calculation/monthly/operated_month.rb +5 -19
- data/lib/zakuro/calculation/option/dropped_date/location.rb +12 -23
- data/lib/zakuro/calculation/option/vanished_date/location.rb +9 -2
- data/lib/zakuro/calculation/range/abstract_full_range.rb +19 -2
- data/lib/zakuro/calculation/range/abstract_operation_range.rb +20 -2
- data/lib/zakuro/calculation/range/dated_full_range.rb +3 -1
- data/lib/zakuro/calculation/range/dated_operation_range.rb +3 -1
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +1 -1
- data/lib/zakuro/calculation/range/named_full_range.rb +3 -1
- data/lib/zakuro/calculation/range/named_operation_range.rb +3 -1
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +2 -1
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +10 -8
- data/lib/zakuro/calculation/stella/solar/abstract_average.rb +8 -34
- data/lib/zakuro/calculation/summary/internal/option.rb +24 -5
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +1 -1
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +1 -1
- data/lib/zakuro/era/japan/gengou/alignment.rb +14 -2
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +83 -25
- data/lib/zakuro/era/japan/gengou/resource/type.rb +81 -26
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +100 -21
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml +1123 -375
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-002-from-north.yaml +487 -163
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-003-modern.yaml +30 -10
- data/lib/zakuro/era/japan/gengou/resource.rb +16 -0
- data/lib/zakuro/era/japan/gengou.rb +7 -4
- data/lib/zakuro/operation/yaml/month.yaml +1 -1
- data/lib/zakuro/output/logger.rb +21 -3
- data/lib/zakuro/tools/remainder_comparer.rb +97 -0
- metadata +6 -2
@@ -5,16 +5,24 @@ last_year:
|
|
5
5
|
japan: 7981
|
6
6
|
western: 9999
|
7
7
|
last_date:
|
8
|
-
|
9
|
-
|
8
|
+
calculation:
|
9
|
+
japan: ''
|
10
|
+
western: ''
|
11
|
+
operation:
|
12
|
+
japan: 令和7981年12月31日
|
13
|
+
western: '9999-12-31'
|
10
14
|
list:
|
11
15
|
- name: 明治
|
12
16
|
start_year:
|
13
17
|
japan: 1
|
14
18
|
western: 1868
|
15
19
|
start_date:
|
16
|
-
|
17
|
-
|
20
|
+
calculation:
|
21
|
+
japan: ''
|
22
|
+
western: ''
|
23
|
+
operation:
|
24
|
+
japan: 明治01年09月08日
|
25
|
+
western: '1868-10-23'
|
18
26
|
disuse:
|
19
27
|
new_year_date: '1868-1-25'
|
20
28
|
note: ''
|
@@ -23,8 +31,12 @@ list:
|
|
23
31
|
japan: 1
|
24
32
|
western: 1912
|
25
33
|
start_date:
|
26
|
-
|
27
|
-
|
34
|
+
calculation:
|
35
|
+
japan: ''
|
36
|
+
western: ''
|
37
|
+
operation:
|
38
|
+
japan: 大正01年07月30日
|
39
|
+
western: '1912-7-30'
|
28
40
|
disuse:
|
29
41
|
new_year_date: '1912-1-1'
|
30
42
|
note: ''
|
@@ -33,8 +45,12 @@ list:
|
|
33
45
|
japan: 1
|
34
46
|
western: 1926
|
35
47
|
start_date:
|
36
|
-
|
37
|
-
|
48
|
+
calculation:
|
49
|
+
japan: ''
|
50
|
+
western: ''
|
51
|
+
operation:
|
52
|
+
japan: 昭和01年12月25日
|
53
|
+
western: '1926-12-25'
|
38
54
|
disuse:
|
39
55
|
new_year_date: '1926-1-1'
|
40
56
|
note: ''
|
@@ -43,8 +59,12 @@ list:
|
|
43
59
|
japan: 1
|
44
60
|
western: 2019
|
45
61
|
start_date:
|
46
|
-
|
47
|
-
|
62
|
+
calculation:
|
63
|
+
japan: ''
|
64
|
+
western: ''
|
65
|
+
operation:
|
66
|
+
japan: 令和01年05月01日
|
67
|
+
western: '2019-5-1'
|
48
68
|
disuse:
|
49
69
|
new_year_date: '2019-1-1'
|
50
70
|
note: ''
|
@@ -27,6 +27,22 @@ module Zakuro
|
|
27
27
|
__dir__
|
28
28
|
))
|
29
29
|
].freeze
|
30
|
+
|
31
|
+
# @return [Array<Set>] 元号セット情報リスト(運用値)
|
32
|
+
OPERATED_LIST = [
|
33
|
+
Parser.run(filepath: File.expand_path(
|
34
|
+
'./resource/yaml/set-001-until-south.yaml',
|
35
|
+
__dir__
|
36
|
+
), operated: true),
|
37
|
+
Parser.run(filepath: File.expand_path(
|
38
|
+
'./resource/yaml/set-002-from-north.yaml',
|
39
|
+
__dir__
|
40
|
+
), operated: true),
|
41
|
+
Parser.run(filepath: File.expand_path(
|
42
|
+
'./resource/yaml/set-003-modern.yaml',
|
43
|
+
__dir__
|
44
|
+
), operated: true)
|
45
|
+
].freeze
|
30
46
|
end
|
31
47
|
end
|
32
48
|
end
|
@@ -26,13 +26,15 @@ module Zakuro
|
|
26
26
|
# @param [Integer] line 行番号
|
27
27
|
# @param [Western::Calendar] start_date 開始日
|
28
28
|
# @param [Western::Calendar] last_date 終了日
|
29
|
+
# @param [True, False] operated 運用値設定
|
29
30
|
#
|
30
31
|
# @return [Array<LinearGengou>] 該当行の元号
|
31
32
|
#
|
32
33
|
def line(line: FIRST_LINE,
|
33
|
-
start_date: Western::Calendar.new, last_date: Western::Calendar.new
|
34
|
+
start_date: Western::Calendar.new, last_date: Western::Calendar.new,
|
35
|
+
operated: false)
|
34
36
|
Alignment.get(
|
35
|
-
line: line, start_date: start_date, last_date: last_date
|
37
|
+
line: line, start_date: start_date, last_date: last_date, operated: operated
|
36
38
|
)
|
37
39
|
end
|
38
40
|
|
@@ -42,11 +44,12 @@ module Zakuro
|
|
42
44
|
# @param [Integer] line 行番号
|
43
45
|
# @param [Western::Calendar] start_date 開始日
|
44
46
|
# @param [Western::Calendar] last_date 終了日
|
47
|
+
# @param [True, False] operated 運用値設定
|
45
48
|
#
|
46
49
|
# @return [Array<LinearGengou>] 該当行の元号
|
47
50
|
#
|
48
|
-
def line_by_name(line: FIRST_LINE, name:)
|
49
|
-
Alignment.get_by_name(line: line, name: name)
|
51
|
+
def line_by_name(line: FIRST_LINE, name:, operated: false)
|
52
|
+
Alignment.get_by_name(line: line, name: name, operated: operated)
|
50
53
|
end
|
51
54
|
end
|
52
55
|
end
|
data/lib/zakuro/output/logger.rb
CHANGED
@@ -9,6 +9,7 @@ module Zakuro
|
|
9
9
|
# @note 本番では使用しない
|
10
10
|
#
|
11
11
|
class Logger
|
12
|
+
# @return [Hash<Symbol, Integer>] ログレベル
|
12
13
|
LEVELS = {
|
13
14
|
none: -1,
|
14
15
|
debug: 0,
|
@@ -17,6 +18,7 @@ module Zakuro
|
|
17
18
|
error: 3
|
18
19
|
}.freeze
|
19
20
|
|
21
|
+
# @return [Integer] 現在ログレベル
|
20
22
|
LEVEL = LEVELS[:none]
|
21
23
|
|
22
24
|
# @return [String] 呼び出し位置
|
@@ -32,7 +34,9 @@ module Zakuro
|
|
32
34
|
# @param [String] messages メッセージ
|
33
35
|
#
|
34
36
|
def debug(*messages)
|
35
|
-
return if
|
37
|
+
return if none?
|
38
|
+
|
39
|
+
return if LEVEL >= LEVELS[:debug]
|
36
40
|
|
37
41
|
output('DEBUG', *messages)
|
38
42
|
end
|
@@ -43,7 +47,9 @@ module Zakuro
|
|
43
47
|
# @param [String] messages メッセージ
|
44
48
|
#
|
45
49
|
def info(*messages)
|
46
|
-
return if
|
50
|
+
return if none?
|
51
|
+
|
52
|
+
return if LEVEL >= LEVELS[:info]
|
47
53
|
|
48
54
|
output('INFO', *messages)
|
49
55
|
end
|
@@ -55,7 +61,9 @@ module Zakuro
|
|
55
61
|
# @param [String] messages メッセージ
|
56
62
|
#
|
57
63
|
def error(error, *messages)
|
58
|
-
return if
|
64
|
+
return if none?
|
65
|
+
|
66
|
+
return if LEVEL >= LEVELS[:error]
|
59
67
|
|
60
68
|
output('ERROR', *messages)
|
61
69
|
output('ERROR', error.message)
|
@@ -64,6 +72,16 @@ module Zakuro
|
|
64
72
|
|
65
73
|
private
|
66
74
|
|
75
|
+
#
|
76
|
+
# 出力なしか
|
77
|
+
#
|
78
|
+
# @return [True] 出力なし
|
79
|
+
# @return [False] 出力あり
|
80
|
+
#
|
81
|
+
def none?
|
82
|
+
LEVEL < LEVELS[:debug]
|
83
|
+
end
|
84
|
+
|
67
85
|
#
|
68
86
|
# 標準出力を行う
|
69
87
|
#
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../output/logger'
|
4
|
+
|
5
|
+
require_relative '../calculation/cycle/abstract_remainder'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
#
|
10
|
+
# Tools 汎用メソッド群
|
11
|
+
#
|
12
|
+
module Tools
|
13
|
+
#
|
14
|
+
# RemainderComparer 大余小余比較
|
15
|
+
#
|
16
|
+
module RemainderComparer
|
17
|
+
LOGGER = Output::Logger.new(location: 'RemainderComparer')
|
18
|
+
|
19
|
+
class << self
|
20
|
+
#
|
21
|
+
# 大余を基準に範囲チェックをする
|
22
|
+
#
|
23
|
+
# 次のパターンで用いる
|
24
|
+
# 1. 月内(当月朔日から当月末日(来月朔日の前日)の間)に二十四節気があるか
|
25
|
+
# * target: 二十四節気
|
26
|
+
# * start: 当月朔日
|
27
|
+
# * last: 次月朔日
|
28
|
+
# 2. ある二十四節気に対象の日があるか
|
29
|
+
# * target: 対象の日
|
30
|
+
# * start: 二十四節気
|
31
|
+
# * last: 次の二十四節気
|
32
|
+
#
|
33
|
+
# @param [Calcuration::Cycle::AbstractRemainder] target 対象日
|
34
|
+
# @param [Calcuration::Cycle::AbstractRemainder] start 範囲開始
|
35
|
+
# @param [Calcuration::Cycle::AbstractRemainder] last 範囲終了
|
36
|
+
#
|
37
|
+
# @return [True] 対象日がある
|
38
|
+
# @return [False] 対象日がない
|
39
|
+
#
|
40
|
+
def in_range?(target:, start:, last:)
|
41
|
+
# 『日本暦日便覧』では下記5日を没日ありとしている
|
42
|
+
# これは二十四節気の小余と秒が0の場合に限って、範囲を翌日にずらすことを指している
|
43
|
+
#
|
44
|
+
# * 貞観12年7月18日
|
45
|
+
# * 天喜5年3月11日
|
46
|
+
# * 寛元1年11月4日
|
47
|
+
# * 永享2年7月26日
|
48
|
+
# * 元和3年3月19日
|
49
|
+
#
|
50
|
+
last_day = last.only_day? ? last.day + 1 : last.day
|
51
|
+
in_range_day?(target: target.day, start: start.day, last: last_day)
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# 大余を基準に範囲チェックをする
|
56
|
+
#
|
57
|
+
# @param [Calcuration::Cycle::AbstractRemainder] target 対象日
|
58
|
+
# @param [Calcuration::Cycle::AbstractRemainder] start 範囲開始
|
59
|
+
# @param [Integer] limit 大余上限
|
60
|
+
#
|
61
|
+
# @return [True] 対象日がある
|
62
|
+
# @return [False] 対象日がない
|
63
|
+
#
|
64
|
+
def in_limit?(target:, start:, limit:)
|
65
|
+
last_day = start.add_day(limit).day
|
66
|
+
|
67
|
+
in_range_day?(target: target.day, start: start.day, last: last_day)
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
#
|
73
|
+
# 大余を基準に範囲チェックをする
|
74
|
+
#
|
75
|
+
# @note 大余60で一巡するため 以下2パターンがある
|
76
|
+
# * start <= last : (二十四節気) >= start && (二十四節気) < last
|
77
|
+
# * start > last : (二十四節気) >= start || (二十四節気) < last
|
78
|
+
#
|
79
|
+
# @param [Integer] target 対象日
|
80
|
+
# @param [Integer] start 範囲開始
|
81
|
+
# @param [Integer] last 範囲終了
|
82
|
+
#
|
83
|
+
# @return [True] 対象日がある
|
84
|
+
# @return [False] 対象日がない
|
85
|
+
#
|
86
|
+
def in_range_day?(target:, start:, last:)
|
87
|
+
start_over = (target >= start)
|
88
|
+
last_under = (target < last)
|
89
|
+
|
90
|
+
return start_over && last_under if start <= last
|
91
|
+
|
92
|
+
start_over || last_under
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
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.9.
|
4
|
+
version: 0.9.3
|
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: 2023-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: mainly lunar solar calendar
|
14
14
|
email:
|
@@ -86,6 +86,9 @@ files:
|
|
86
86
|
- lib/zakuro/calculation/monthly/const.rb
|
87
87
|
- lib/zakuro/calculation/monthly/first_day.rb
|
88
88
|
- lib/zakuro/calculation/monthly/initialized_month.rb
|
89
|
+
- lib/zakuro/calculation/monthly/meta.rb
|
90
|
+
- lib/zakuro/calculation/monthly/meta/all_solar_term.rb
|
91
|
+
- lib/zakuro/calculation/monthly/meta/meta_collector.rb
|
89
92
|
- lib/zakuro/calculation/monthly/month.rb
|
90
93
|
- lib/zakuro/calculation/monthly/month_label.rb
|
91
94
|
- lib/zakuro/calculation/monthly/operated_month.rb
|
@@ -181,6 +184,7 @@ files:
|
|
181
184
|
- lib/zakuro/result/operation/month/annotation.rb
|
182
185
|
- lib/zakuro/result/operation/month/history.rb
|
183
186
|
- lib/zakuro/result/result.rb
|
187
|
+
- lib/zakuro/tools/remainder_comparer.rb
|
184
188
|
- lib/zakuro/tools/stringifier.rb
|
185
189
|
- lib/zakuro/tools/typeconv.rb
|
186
190
|
- lib/zakuro/tools/typeof.rb
|