mk_cal_jpl 0.2.4 → 0.3.2
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 +77 -42
- data/lib/mk_cal_jpl/const.rb +33 -30
- data/lib/mk_cal_jpl/version.rb +1 -1
- data/mk_cal_jpl.gemspec +4 -2
- metadata +14 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b74745baec925d50fe502c3db8fefd5b3786a63fd945064cd93e961344b716fb
|
4
|
+
data.tar.gz: a0a2b50fd08e952b17ad8b4210cabc3c3bf57f1b91f9a52697e660fb3e3df060
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cf43e547defbe689daedfb2b9cc213de1e2ba4576fb071c9afef17d100d3abc7ef56409aab0a894010be9e6fc3afe268ee909be859d26b021d68c5b3d15c0a3
|
7
|
+
data.tar.gz: baba7690a994b197a2de06c647ee1060d8d339f4471431caac75c085726dcba6daaf26dd4820489e5e2b599bff5c908d8a5f505e3a364109edee6996e1ea1bc6
|
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)
|
@@ -35,8 +35,8 @@ 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
42
|
Const::HOLIDAY.each do |id, month, day, kbn, year_s, year_e, name|
|
@@ -77,34 +77,17 @@ module MkCalJpl
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
# 国民の休日計算
|
81
|
-
# ( 「国民の祝日」で前後を挟まれた「国民の祝日」でない日 )
|
82
|
-
# ( 年またぎは考慮していない(今のところ不要) )
|
83
|
-
year_s_k = Const::HOLIDAY.select { |a| a[0] == 90 }[0][4]
|
84
|
-
0.upto(holiday_0.length - 2) do |i|
|
85
|
-
m_0, d_0 = holiday_0[i ][0, 2]
|
86
|
-
m_1, d_1 = holiday_0[i + 1][0, 2]
|
87
|
-
jd_0 = gc2jd(year, m_0, d_0)
|
88
|
-
jd_1 = gc2jd(year, m_1, d_1)
|
89
|
-
if jd_0 + 2 == jd_1
|
90
|
-
jd = jd_0 + 1
|
91
|
-
m, d = jd2ymd(jd)[1, 2]
|
92
|
-
yobi = Const::YOBI[Const::YOBI.index(holiday_0[i][4]) + 1]
|
93
|
-
holiday_1 << [m, d, 90, jd, yobi]
|
94
|
-
end
|
95
|
-
end if year < year_s_k
|
96
|
-
|
97
80
|
# 振替休日計算
|
98
81
|
# ( 「国民の祝日」が日曜日に当たるときは、
|
99
82
|
# その日後においてその日に最も近い「国民の祝日」でない日 )
|
100
|
-
year_s_f = Const::HOLIDAY.select { |a| a[0] ==
|
83
|
+
year_s_f = Const::HOLIDAY.select { |a| a[0] == 90 }[0][4]
|
101
84
|
0.upto(holiday_0.length - 1) do |i|
|
102
85
|
if holiday_0[i][4] == "日"
|
103
86
|
next_jd = holiday_0[i][3] + 1
|
104
87
|
next_yobi = Const::YOBI[Const::YOBI.index(holiday_0[i][4]) + 1]
|
105
88
|
if i == holiday_0.length - 1
|
106
89
|
wk_ymd = jd2ymd(next_jd)
|
107
|
-
wk_ary = [wk_ymd[1], wk_ymd[2],
|
90
|
+
wk_ary = [wk_ymd[1], wk_ymd[2], 90, next_jd, next_yobi]
|
108
91
|
else
|
109
92
|
flg_furikae = 0
|
110
93
|
plus_day = 1
|
@@ -118,15 +101,32 @@ module MkCalJpl
|
|
118
101
|
else
|
119
102
|
flg_furikae = 1
|
120
103
|
wk_ymd = jd2ymd(next_jd)
|
121
|
-
wk_ary =[wk_ymd[1], wk_ymd[2],
|
104
|
+
wk_ary =[wk_ymd[1], wk_ymd[2], 90, next_jd, next_yobi]
|
122
105
|
end
|
123
106
|
end
|
124
107
|
end
|
125
108
|
end
|
126
|
-
|
109
|
+
holiday_1 << wk_ary
|
110
|
+
end
|
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
127
|
end
|
128
|
-
end if year
|
129
|
-
return (holiday_0
|
128
|
+
end if year >= year_s_k
|
129
|
+
return merge_sort(holiday_0, holiday_1, holiday_2)
|
130
130
|
end
|
131
131
|
|
132
132
|
#=========================================================================
|
@@ -156,12 +156,16 @@ module MkCalJpl
|
|
156
156
|
lsun_today = compute_lambda(jd)
|
157
157
|
# 計算対象日の翌日の太陽の黄経
|
158
158
|
lsun_tomorrow = compute_lambda(jd + 1)
|
159
|
+
# ====[ 190919:DEL ]===>
|
159
160
|
# 計算対象日の5日前の太陽の黄経(社日計算用)
|
160
|
-
lsun_before_5 = compute_lambda(jd - 5)
|
161
|
+
#lsun_before_5 = compute_lambda(jd - 5)
|
162
|
+
# <===[ 190919:DEL ]====
|
161
163
|
# 計算対象日の4日前の太陽の黄経(社日計算用)
|
162
164
|
lsun_before_4 = compute_lambda(jd - 4)
|
165
|
+
# ====[ 190919:DEL ]===>
|
163
166
|
# 計算対象日の5日後の太陽の黄経(社日計算用)
|
164
|
-
lsun_after_5 = compute_lambda(jd + 5)
|
167
|
+
#lsun_after_5 = compute_lambda(jd + 5)
|
168
|
+
# <===[ 190919:DEL ]====
|
165
169
|
# 計算対象日の6日後の太陽の黄経(社日計算用)
|
166
170
|
lsun_after_6 = compute_lambda(jd + 6)
|
167
171
|
# 太陽の黄経の整数部分( 土用, 入梅, 半夏生 計算用 )
|
@@ -205,14 +209,19 @@ module MkCalJpl
|
|
205
209
|
if compute_sekki_24(jd + 5) == "春分"
|
206
210
|
# 春分の日の黄経(太陽)と翌日の黄経(太陽)の中間点が
|
207
211
|
# 0度(360度)以上なら、春分点が午前と判断
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
# 春分の日の黄経(太陽)と翌日の黄経(太陽)の中間点が
|
213
|
-
# 0度(360度)未満なら、春分点が午後と判断
|
214
|
-
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 ]===~
|
215
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 ]===~
|
216
225
|
end
|
217
226
|
# 5:土用入(春) ( 黄経(太陽) = 27度 )
|
218
227
|
unless lsun_today0 == lsun_tomorrow0
|
@@ -270,14 +279,19 @@ module MkCalJpl
|
|
270
279
|
if compute_sekki_24(jd + 5) == "秋分"
|
271
280
|
# 秋分の日の黄経(太陽)と翌日の黄経(太陽)の中間点が
|
272
281
|
# 180度以上なら、秋分点が午前と判断
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
# 秋分の日の黄経(太陽)と翌日の黄経(太陽)の中間点が
|
278
|
-
# 180度未満なら、秋分点が午後と判断
|
279
|
-
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 ]====
|
280
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 ]====
|
281
295
|
end
|
282
296
|
# 16:土用入(秋) ( 黄経(太陽) = 207度 )
|
283
297
|
unless lsun_today0 == lsun_tomorrow0
|
@@ -661,6 +675,27 @@ module MkCalJpl
|
|
661
675
|
lmd = a.moon[1][0] * 180.0 / Math::PI
|
662
676
|
return lmd
|
663
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
|
664
699
|
end
|
665
700
|
end
|
666
701
|
|
data/lib/mk_cal_jpl/const.rb
CHANGED
@@ -41,36 +41,39 @@ module MkCalJpl
|
|
41
41
|
[ 1, 1, 15, 0, 1949, 1999, "成人の日" ],
|
42
42
|
[ 2, 1, 0, 2, 2000, 9999, "成人の日" ],
|
43
43
|
[ 3, 2, 11, 0, 1967, 9999, "建国記念の日" ],
|
44
|
-
[ 4,
|
45
|
-
[ 5,
|
46
|
-
[ 6,
|
47
|
-
[ 7, 4,
|
48
|
-
[ 8,
|
49
|
-
[ 9,
|
50
|
-
[10,
|
51
|
-
[11,
|
52
|
-
[12,
|
53
|
-
[13,
|
54
|
-
[14,
|
55
|
-
[15,
|
56
|
-
[16,
|
57
|
-
[17,
|
58
|
-
[18,
|
59
|
-
[19,
|
60
|
-
[20,
|
61
|
-
[21,
|
62
|
-
[22,
|
63
|
-
[23,
|
64
|
-
[24,
|
65
|
-
[25,
|
66
|
-
[26,
|
67
|
-
[27,
|
68
|
-
[28,
|
69
|
-
[29,
|
70
|
-
[30,
|
71
|
-
[31,
|
72
|
-
[
|
73
|
-
[
|
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, "国民の休日" ]
|
74
77
|
]
|
75
78
|
end
|
76
79
|
end
|
data/lib/mk_cal_jpl/version.rb
CHANGED
data/mk_cal_jpl.gemspec
CHANGED
@@ -29,7 +29,9 @@ 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"
|
33
|
-
spec.add_development_dependency "
|
32
|
+
#spec.add_development_dependency "bundler", "~> 1.12"
|
33
|
+
spec.add_development_dependency "bundler", ">= 2.2.10"
|
34
|
+
#spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
34
36
|
spec.add_development_dependency "rspec", "~> 3.0"
|
35
37
|
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.2
|
4
|
+
version: 0.3.2
|
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,30 +42,30 @@ 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
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 12.3.3
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 12.3.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
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: []
|