mk_cal_jpl 0.2.3 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mk_cal_jpl/compute.rb +80 -42
- data/lib/mk_cal_jpl/const.rb +37 -18
- data/lib/mk_cal_jpl/version.rb +1 -1
- data/mk_cal_jpl.gemspec +2 -1
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83c9191bfe0b9a2843b0a7f0babb5308c8305078816903cd55dd6c6a03ffa2dd
|
4
|
+
data.tar.gz: 0dfe5dc82f6787ca7e252b7958ac7f9a78d6b23c585d6e5b8443c3c207ee290a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e445fb95dda1cdbedec14662ab9a369a2e339953740f1cd050d21e036a16affbe526f142f167fed59c343e37453d97def2d4eedf5f859fad2eb5fa6810672a59
|
7
|
+
data.tar.gz: 564a9bff2acd0e765b6e04c9cc76a1a5fa25ecd986bbd564098f6ac3410306c0a1328a478df3c0f2098376a15c1671dcd17f20039197cff6606c6711aed503fc
|
data/lib/mk_cal_jpl/compute.rb
CHANGED
@@ -10,7 +10,7 @@ module MkCalJpl
|
|
10
10
|
# @param: year
|
11
11
|
# @param: month
|
12
12
|
# @param: day
|
13
|
-
# @return: holiday (
|
13
|
+
# @return: holiday (漢字)
|
14
14
|
#=========================================================================
|
15
15
|
def compute_holiday(year, month, day)
|
16
16
|
holidays = get_holidays(year)
|
@@ -23,7 +23,7 @@ module MkCalJpl
|
|
23
23
|
end
|
24
24
|
holiday = ""
|
25
25
|
res = Const::HOLIDAY.select { |h| h[0] == code }
|
26
|
-
holiday = res[0][
|
26
|
+
holiday = res[0][6] unless res == []
|
27
27
|
return holiday
|
28
28
|
end
|
29
29
|
|
@@ -35,12 +35,13 @@ module MkCalJpl
|
|
35
35
|
#=========================================================================
|
36
36
|
def get_holidays(year)
|
37
37
|
holiday_0 = Array.new # 変動の祝日用
|
38
|
-
holiday_1 = Array.new #
|
39
|
-
holiday_2 = Array.new #
|
38
|
+
holiday_1 = Array.new # 振替休日用
|
39
|
+
holiday_2 = Array.new # 国民の休日用
|
40
40
|
|
41
41
|
# 変動の祝日の日付・曜日を計算 ( 振替休日,国民の休日を除く )
|
42
|
-
Const::HOLIDAY.each do |id, month, day, kbn, name|
|
42
|
+
Const::HOLIDAY.each do |id, month, day, kbn, year_s, year_e, name|
|
43
43
|
next if kbn > 7
|
44
|
+
next if year < year_s || year_e < year
|
44
45
|
if kbn == 0 # 月日が既定のもの
|
45
46
|
jd_jst = gc2jd(year, month, day)
|
46
47
|
yobi = compute_yobi(jd_jst)
|
@@ -76,32 +77,17 @@ module MkCalJpl
|
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
79
|
-
# 国民の休日計算
|
80
|
-
# ( 「国民の祝日」で前後を挟まれた「国民の祝日」でない日 )
|
81
|
-
# ( 年またぎは考慮していない(今のところ不要) )
|
82
|
-
0.upto(holiday_0.length - 2) do |i|
|
83
|
-
m_0, d_0 = holiday_0[i ][0, 2]
|
84
|
-
m_1, d_1 = holiday_0[i + 1][0, 2]
|
85
|
-
jd_0 = gc2jd(year, m_0, d_0)
|
86
|
-
jd_1 = gc2jd(year, m_1, d_1)
|
87
|
-
if jd_0 + 2 == jd_1
|
88
|
-
jd = jd_0 + 1
|
89
|
-
m, d = jd2ymd(jd)[1, 2]
|
90
|
-
yobi = Const::YOBI[Const::YOBI.index(holiday_0[i][4]) + 1]
|
91
|
-
holiday_1 << [m, d, 90, jd, yobi]
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
80
|
# 振替休日計算
|
96
81
|
# ( 「国民の祝日」が日曜日に当たるときは、
|
97
82
|
# その日後においてその日に最も近い「国民の祝日」でない日 )
|
83
|
+
year_s_f = Const::HOLIDAY.select { |a| a[0] == 90 }[0][4]
|
98
84
|
0.upto(holiday_0.length - 1) do |i|
|
99
85
|
if holiday_0[i][4] == "日"
|
100
86
|
next_jd = holiday_0[i][3] + 1
|
101
87
|
next_yobi = Const::YOBI[Const::YOBI.index(holiday_0[i][4]) + 1]
|
102
88
|
if i == holiday_0.length - 1
|
103
89
|
wk_ymd = jd2ymd(next_jd)
|
104
|
-
wk_ary = [wk_ymd[1], wk_ymd[2],
|
90
|
+
wk_ary = [wk_ymd[1], wk_ymd[2], 90, next_jd, next_yobi]
|
105
91
|
else
|
106
92
|
flg_furikae = 0
|
107
93
|
plus_day = 1
|
@@ -115,15 +101,32 @@ module MkCalJpl
|
|
115
101
|
else
|
116
102
|
flg_furikae = 1
|
117
103
|
wk_ymd = jd2ymd(next_jd)
|
118
|
-
wk_ary =[wk_ymd[1], wk_ymd[2],
|
104
|
+
wk_ary =[wk_ymd[1], wk_ymd[2], 90, next_jd, next_yobi]
|
119
105
|
end
|
120
106
|
end
|
121
107
|
end
|
122
108
|
end
|
123
|
-
|
109
|
+
holiday_1 << wk_ary
|
124
110
|
end
|
125
|
-
end
|
126
|
-
|
111
|
+
end if year >= year_s_f
|
112
|
+
|
113
|
+
# 国民の休日計算
|
114
|
+
# ( 「国民の祝日」で前後を挟まれた「国民の祝日」でない日 )
|
115
|
+
# ( 年またぎは考慮していない(今のところ不要) )
|
116
|
+
year_s_k = Const::HOLIDAY.select { |a| a[0] == 91 }[0][4]
|
117
|
+
0.upto(holiday_0.length - 2) do |i|
|
118
|
+
m_0, d_0 = holiday_0[i ][0, 2]
|
119
|
+
m_1, d_1 = holiday_0[i + 1][0, 2]
|
120
|
+
jd_0 = gc2jd(year, m_0, d_0)
|
121
|
+
jd_1 = gc2jd(year, m_1, d_1)
|
122
|
+
if jd_0 + 2 == jd_1
|
123
|
+
jd = jd_0 + 1
|
124
|
+
m, d = jd2ymd(jd)[1, 2]
|
125
|
+
yobi = Const::YOBI[Const::YOBI.index(holiday_0[i][4]) + 1]
|
126
|
+
holiday_2 << [m, d, 91, jd, yobi]
|
127
|
+
end
|
128
|
+
end if year >= year_s_k
|
129
|
+
return merge_sort(holiday_0, holiday_1, holiday_2)
|
127
130
|
end
|
128
131
|
|
129
132
|
#=========================================================================
|
@@ -153,12 +156,16 @@ module MkCalJpl
|
|
153
156
|
lsun_today = compute_lambda(jd)
|
154
157
|
# 計算対象日の翌日の太陽の黄経
|
155
158
|
lsun_tomorrow = compute_lambda(jd + 1)
|
159
|
+
# ====[ 190919:DEL ]===>
|
156
160
|
# 計算対象日の5日前の太陽の黄経(社日計算用)
|
157
|
-
lsun_before_5 = compute_lambda(jd - 5)
|
161
|
+
#lsun_before_5 = compute_lambda(jd - 5)
|
162
|
+
# <===[ 190919:DEL ]====
|
158
163
|
# 計算対象日の4日前の太陽の黄経(社日計算用)
|
159
164
|
lsun_before_4 = compute_lambda(jd - 4)
|
165
|
+
# ====[ 190919:DEL ]===>
|
160
166
|
# 計算対象日の5日後の太陽の黄経(社日計算用)
|
161
|
-
lsun_after_5 = compute_lambda(jd + 5)
|
167
|
+
#lsun_after_5 = compute_lambda(jd + 5)
|
168
|
+
# <===[ 190919:DEL ]====
|
162
169
|
# 計算対象日の6日後の太陽の黄経(社日計算用)
|
163
170
|
lsun_after_6 = compute_lambda(jd + 6)
|
164
171
|
# 太陽の黄経の整数部分( 土用, 入梅, 半夏生 計算用 )
|
@@ -202,14 +209,19 @@ module MkCalJpl
|
|
202
209
|
if compute_sekki_24(jd + 5) == "春分"
|
203
210
|
# 春分の日の黄経(太陽)と翌日の黄経(太陽)の中間点が
|
204
211
|
# 0度(360度)以上なら、春分点が午前と判断
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
# 春分の日の黄経(太陽)と翌日の黄経(太陽)の中間点が
|
210
|
-
# 0度(360度)未満なら、春分点が午後と判断
|
211
|
-
zassetsu << 4 if (lsun_before_4 + lsun_before_5 + 360) / 2.0 < 360
|
212
|
+
# ====[ 190919:UPD ]===>
|
213
|
+
#zassetsu << 4 if (lsun_after_5 + lsun_after_6 + 360) / 2.0 >= 360
|
214
|
+
zassetsu << 4
|
215
|
+
# <===[ 190919:UPD ]===~
|
212
216
|
end
|
217
|
+
# ====[ 190919:DEL ]===>
|
218
|
+
## [ 5日前 ]
|
219
|
+
#if compute_sekki_24(jd - 5) == "春分"
|
220
|
+
# # 春分の日の黄経(太陽)と翌日の黄経(太陽)の中間点が
|
221
|
+
# # 0度(360度)未満なら、春分点が午後と判断
|
222
|
+
# zassetsu << 4 if (lsun_before_4 + lsun_before_5 + 360) / 2.0 < 360
|
223
|
+
#end
|
224
|
+
# <===[ 190919:DEL ]===~
|
213
225
|
end
|
214
226
|
# 5:土用入(春) ( 黄経(太陽) = 27度 )
|
215
227
|
unless lsun_today0 == lsun_tomorrow0
|
@@ -267,14 +279,19 @@ module MkCalJpl
|
|
267
279
|
if compute_sekki_24(jd + 5) == "秋分"
|
268
280
|
# 秋分の日の黄経(太陽)と翌日の黄経(太陽)の中間点が
|
269
281
|
# 180度以上なら、秋分点が午前と判断
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
# 秋分の日の黄経(太陽)と翌日の黄経(太陽)の中間点が
|
275
|
-
# 180度未満なら、秋分点が午後と判断
|
276
|
-
zassetsu << 15 if (lsun_before_4 + lsun_before_5) / 2.0 < 180
|
282
|
+
# ====[ 190919:UPD ]===>
|
283
|
+
#zassetsu << 15 if (lsun_after_5 + lsun_after_6) / 2.0 >= 180
|
284
|
+
zassetsu << 15
|
285
|
+
# <===[ 190919:UPD ]====
|
277
286
|
end
|
287
|
+
# ====[ 190919:DEL ]===>
|
288
|
+
## [ 5日前 ]
|
289
|
+
#if compute_sekki_24(jd - 5) == "秋分"
|
290
|
+
# # 秋分の日の黄経(太陽)と翌日の黄経(太陽)の中間点が
|
291
|
+
# # 180度未満なら、秋分点が午後と判断
|
292
|
+
# zassetsu << 15 if (lsun_before_4 + lsun_before_5) / 2.0 < 180
|
293
|
+
#end
|
294
|
+
# <===[ 190919:DEL ]====
|
278
295
|
end
|
279
296
|
# 16:土用入(秋) ( 黄経(太陽) = 207度 )
|
280
297
|
unless lsun_today0 == lsun_tomorrow0
|
@@ -658,6 +675,27 @@ module MkCalJpl
|
|
658
675
|
lmd = a.moon[1][0] * 180.0 / Math::PI
|
659
676
|
return lmd
|
660
677
|
end
|
678
|
+
|
679
|
+
private
|
680
|
+
|
681
|
+
# マージ&ソート
|
682
|
+
# * さらに、「振替休日」と「国民の休日」がダブる場合は、
|
683
|
+
# 「振替休日」を優先
|
684
|
+
def merge_sort(hol_0, hol_1, hol_2)
|
685
|
+
data = Array.new
|
686
|
+
data_src = (hol_0 + hol_1 + hol_2).sort
|
687
|
+
data_src.each_with_index do |d, i|
|
688
|
+
if i == 0
|
689
|
+
data << d
|
690
|
+
next
|
691
|
+
end
|
692
|
+
if data_src[i - 1][0..2] == d[0..2]
|
693
|
+
next if data_src[i - 1][3] == 90 && d[3] == 91
|
694
|
+
end
|
695
|
+
data << d
|
696
|
+
end
|
697
|
+
return data
|
698
|
+
end
|
661
699
|
end
|
662
700
|
end
|
663
701
|
|
data/lib/mk_cal_jpl/const.rb
CHANGED
@@ -37,24 +37,43 @@ module MkCalJpl
|
|
37
37
|
"土用入(秋)", "土用入(冬)"
|
38
38
|
]
|
39
39
|
HOLIDAY = [
|
40
|
-
[ 0, 1, 1, 0, "元日"
|
41
|
-
[ 1, 1,
|
42
|
-
[ 2, 2,
|
43
|
-
[ 3,
|
44
|
-
[ 4,
|
45
|
-
[ 5,
|
46
|
-
[ 6,
|
47
|
-
[ 7,
|
48
|
-
[ 8,
|
49
|
-
[ 9,
|
50
|
-
[10,
|
51
|
-
[11,
|
52
|
-
[12,
|
53
|
-
[13,
|
54
|
-
[14,
|
55
|
-
[15,
|
56
|
-
[
|
57
|
-
[
|
40
|
+
[ 0, 1, 1, 0, 1949, 9999, "元日" ],
|
41
|
+
[ 1, 1, 15, 0, 1949, 1999, "成人の日" ],
|
42
|
+
[ 2, 1, 0, 2, 2000, 9999, "成人の日" ],
|
43
|
+
[ 3, 2, 11, 0, 1967, 9999, "建国記念の日" ],
|
44
|
+
[ 4, 2, 23, 0, 2020, 9999, "天皇誕生日" ],
|
45
|
+
[ 5, 2, 24, 0, 1989, 1989, "昭和天皇の大喪の礼"],
|
46
|
+
[ 6, 3, 0, 4, 1949, 9999, "春分の日" ],
|
47
|
+
[ 7, 4, 10, 0, 1959, 1959, "明仁親王の結婚の儀"],
|
48
|
+
[ 8, 4, 29, 0, 1949, 1988, "天皇誕生日" ],
|
49
|
+
[ 9, 4, 29, 0, 1989, 2006, "みどりの日" ],
|
50
|
+
[10, 4, 29, 0, 2007, 9999, "昭和の日" ],
|
51
|
+
[11, 5, 1, 0, 2019, 2019, "天皇の即位の日" ],
|
52
|
+
[12, 5, 3, 0, 1949, 9999, "憲法記念日" ],
|
53
|
+
[13, 5, 4, 0, 2007, 9999, "みどりの日" ],
|
54
|
+
[14, 5, 5, 0, 1949, 9999, "こどもの日" ],
|
55
|
+
[15, 6, 9, 0, 1993, 1993, "徳仁親王の結婚の儀"],
|
56
|
+
[16, 7, 20, 0, 1996, 2002, "海の日" ],
|
57
|
+
[17, 7, 23, 0, 2020, 2020, "海の日" ],
|
58
|
+
[18, 7, 24, 0, 2020, 2020, "スポーツの日" ],
|
59
|
+
[19, 7, 0, 3, 2003, 2019, "海の日" ],
|
60
|
+
[20, 7, 0, 3, 2021, 9999, "海の日" ],
|
61
|
+
[21, 8, 10, 0, 2020, 2020, "山の日" ],
|
62
|
+
[22, 8, 11, 0, 2016, 2019, "山の日" ],
|
63
|
+
[23, 8, 11, 0, 2021, 9999, "山の日" ],
|
64
|
+
[24, 9, 15, 0, 1966, 2002, "敬老の日" ],
|
65
|
+
[25, 9, 0, 3, 2003, 9999, "敬老の日" ],
|
66
|
+
[26, 9, 0, 4, 1948, 9999, "秋分の日" ],
|
67
|
+
[27, 10, 10, 0, 1966, 1999, "体育の日" ],
|
68
|
+
[28, 10, 22, 0, 2019, 2019, "即位礼正殿の儀" ],
|
69
|
+
[29, 10, 0, 2, 2000, 2019, "体育の日" ],
|
70
|
+
[30, 10, 0, 2, 2021, 9999, "スポーツの日" ],
|
71
|
+
[31, 11, 3, 0, 1948, 9999, "文化の日" ],
|
72
|
+
[32, 11, 12, 0, 1990, 1990, "即位礼正殿の儀" ],
|
73
|
+
[33, 11, 23, 0, 1948, 9999, "勤労感謝の日" ],
|
74
|
+
[34, 12, 23, 0, 1989, 2018, "天皇誕生日" ],
|
75
|
+
[90, 0, 0, 8, 1973, 9999, "振替休日" ], # 1973-04-12 以降
|
76
|
+
[91, 0, 0, 9, 1986, 9999, "国民の休日" ]
|
58
77
|
]
|
59
78
|
end
|
60
79
|
end
|
data/lib/mk_cal_jpl/version.rb
CHANGED
data/mk_cal_jpl.gemspec
CHANGED
@@ -29,7 +29,8 @@ Gem::Specification.new do |spec|
|
|
29
29
|
|
30
30
|
spec.add_dependency "mk_apos"
|
31
31
|
spec.add_dependency "mk_coord"
|
32
|
-
spec.add_development_dependency "bundler", "~> 1.12"
|
32
|
+
#spec.add_development_dependency "bundler", "~> 1.12"
|
33
|
+
spec.add_development_dependency "bundler", ">= 2.2.10"
|
33
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
34
35
|
spec.add_development_dependency "rspec", "~> 3.0"
|
35
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mk_cal_jpl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- komasaru
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mk_apos
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.2.10
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2.2.10
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,7 +113,7 @@ homepage: https://github.com/komasaru/mk_cal_jpl
|
|
113
113
|
licenses:
|
114
114
|
- MIT
|
115
115
|
metadata: {}
|
116
|
-
post_install_message:
|
116
|
+
post_install_message:
|
117
117
|
rdoc_options: []
|
118
118
|
require_paths:
|
119
119
|
- lib
|
@@ -128,9 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
|
-
|
132
|
-
|
133
|
-
signing_key:
|
131
|
+
rubygems_version: 3.2.9
|
132
|
+
signing_key:
|
134
133
|
specification_version: 4
|
135
134
|
summary: Calendar library including Japan's old-calendar, using JPL DE430.
|
136
135
|
test_files: []
|