jpdate 0.2 → 0.2.5
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/README.md +11 -10
- data/bin/jcal +20 -18
- data/lib/jpdate/era.rb +1 -1
- data/lib/jpdate/holiday.rb +8 -3
- data/lib/jpdate/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb06447dae73dee86a7e2ec5eb9362ce017c091314a294e3d77b755f166e5abb
|
4
|
+
data.tar.gz: 86d2ac7cf9cec7537a06603d07dc6a7aa465d859910975b587810418e679165f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '092f9f6aeb3db36358e9c8d2eabce5c3b8ae65fe2854d84f31e3c29da18293741b30b8b8e5afaed881e6021834b5e0b5e9b3893a00c6e88c2ef3c709bb8e32e7'
|
7
|
+
data.tar.gz: 957cc7cadb5716e724b13e5f43be23c86621e4487a73524b2b3ef11407862a6a4de1f74f9f884faeda66cfc917b5e180fef998c61da5128aaa44f0a8213ed60f
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#jcalコマンド & JPDateクラス
|
1
|
+
# jcalコマンド & JPDateクラス
|
2
2
|
|
3
3
|
* jcal : 日本の祝日もちゃんと表示するカレンダー出力コマンド。
|
4
4
|
* JPDate: 祝日名称と年号を返すクラス&モジュール。
|
@@ -12,17 +12,18 @@
|
|
12
12
|
* 日本の暦は、明治6年・1873年1月1日より太陽暦で動いている。(それ以前は太陰暦)
|
13
13
|
* jcal・JPDateは、太陽暦以降の祝日に関する法律に可能な限り準拠しようとしている。
|
14
14
|
|
15
|
-
##Installation インストール
|
15
|
+
## Installation インストール
|
16
16
|
|
17
17
|
$ sudo gem install jpdate
|
18
18
|
|
19
|
-
##Usage 使い方(jcal)
|
19
|
+
## Usage 使い方(jcal)
|
20
20
|
|
21
21
|
Usage: jcal [options] [yyyy|mm] [yyyy|mm] [yyyy|mm]
|
22
22
|
|
23
|
-
-y[NUM]
|
24
|
-
-m[NUM] Show NUM months.
|
23
|
+
-y[NUM] Show NUM years.(0-10)
|
24
|
+
-m[NUM] Show NUM months.
|
25
25
|
-e List with the name of Japanese era.
|
26
|
+
-s, --size=compact|minimum Set width of monthly calendar.
|
26
27
|
|
27
28
|
Example:
|
28
29
|
jcal # Show monthly calendar of this month.
|
@@ -36,7 +37,7 @@
|
|
36
37
|
jcal -m6 2010 1 # Show monthly calendar from Jan.2010 to Jun.2010.
|
37
38
|
jcal 2010 2 8 # Show monthly calendar from Feb.2010 to Aug.2010.
|
38
39
|
|
39
|
-
##Usage 使い方(JPDate, JPDate::Holiday, JPDate::Era)
|
40
|
+
## Usage 使い方(JPDate, JPDate::Holiday, JPDate::Era)
|
40
41
|
|
41
42
|
require 'jpdate'
|
42
43
|
|
@@ -74,21 +75,21 @@
|
|
74
75
|
JPDate::Era.short_name_year(1989)
|
75
76
|
=> ["S64", "H01"]
|
76
77
|
|
77
|
-
##More Document さらなるドキュメント
|
78
|
+
## More Document さらなるドキュメント
|
78
79
|
|
79
|
-
###gemサーバーを起動する方法
|
80
|
+
### gemサーバーを起動する方法
|
80
81
|
$ gem server -l
|
81
82
|
|
82
83
|
* gemサーバー起動後、以下のURLを開く。
|
83
84
|
* http://0.0.0.0:8808/doc_root/jpdate-0.1/
|
84
85
|
|
85
|
-
###Rdocを生成する方法
|
86
|
+
### Rdocを生成する方法
|
86
87
|
|
87
88
|
$ cd ~/Desktop
|
88
89
|
$ rdoc $(dirname `gem which jpdate`)
|
89
90
|
$ open doc/index.html
|
90
91
|
|
91
|
-
##Contributing 貢献
|
92
|
+
## Contributing 貢献
|
92
93
|
|
93
94
|
1. フォークする。 ( https://github.com/[my-github-username]/sample/fork )
|
94
95
|
2. フィーチャーブランチを作る。 (`git checkout -b my-new-feature`)
|
data/bin/jcal
CHANGED
@@ -30,9 +30,10 @@ module Jcal
|
|
30
30
|
|
31
31
|
module_function
|
32
32
|
|
33
|
-
def render_matrix(y, m)
|
34
|
-
|
35
|
-
|
33
|
+
def render_matrix(y, m, cell=16)
|
34
|
+
m = 12 if m == 0
|
35
|
+
title = (sprintf("#{JPDate::Era.name_year(y, m).join('/')} %4d年 %2d月", y, m)).center_ja(cell * 7)
|
36
|
+
week_names = WEEK_JA.map {|s| s.rjust_ja(cell)}
|
36
37
|
week_names[0] = "\e[31m#{week_names[0]}\e[0m"
|
37
38
|
week_names[6] = "\e[36m#{week_names[6]}\e[0m"
|
38
39
|
puts title, week_names.join
|
@@ -41,15 +42,16 @@ module Jcal
|
|
41
42
|
end_date = JPDate.new(y, m, -1) + (6 - JPDate.new(y, m, -1).wday)
|
42
43
|
(start_date..end_date).each_slice(7) do |week|
|
43
44
|
week.each do |date|
|
44
|
-
today_marker = date == Date.today ? "\e[7m" : ''
|
45
|
-
|
45
|
+
today_marker = date.month == m && date == Date.today ? "\e[7m" : ''
|
46
|
+
month_marker = date.month != m ? "\e[2m" : ''
|
47
|
+
holiday_name = date.holiday.to_s[0, cell/2 - 2].rjust_ja(cell - 2)
|
46
48
|
fgcolor = case
|
47
|
-
when date.month != m then
|
49
|
+
when date.month != m then 0
|
48
50
|
when date.wday == 0, date.holiday then 31
|
49
51
|
when date.wday == 6 then 36
|
50
52
|
else 0
|
51
53
|
end
|
52
|
-
printf "\e[%dm%s%s%2d\e[0m", fgcolor, holiday_name, today_marker, date.day
|
54
|
+
printf "\e[%dm%s%s%s%2d\e[0m", fgcolor, month_marker, holiday_name, today_marker, date.day
|
53
55
|
end
|
54
56
|
puts
|
55
57
|
end
|
@@ -79,14 +81,11 @@ module Jcal
|
|
79
81
|
list366.each {|list| puts list}
|
80
82
|
end
|
81
83
|
|
82
|
-
def matrix(base_year, start_month, end_month=start_month)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
(
|
87
|
-
else
|
88
|
-
(start_month..12 ).each {|i| render_matrix(base_year , i)}
|
89
|
-
( 1..end_month).each {|i| render_matrix(base_year + 1, i)}
|
84
|
+
def matrix(size, base_year, start_month, end_month=start_month)
|
85
|
+
cell_size = 16 - size*6
|
86
|
+
end_month += 12 if start_month > end_month
|
87
|
+
(start_month..end_month).each do |i|
|
88
|
+
render_matrix(base_year + (i / 12.0).ceil - 1, i % 12, cell_size)
|
90
89
|
end
|
91
90
|
end
|
92
91
|
|
@@ -101,11 +100,13 @@ require 'optparse'
|
|
101
100
|
# オプション解析
|
102
101
|
options = {}
|
103
102
|
OptionParser.new do |opt|
|
103
|
+
opt.version = JPDate::VERSION
|
104
104
|
opt.banner = 'Usage: jcal [options] [yyyy|mm] [yyyy|mm] [yyyy|mm]'
|
105
105
|
opt.separator('')
|
106
|
-
opt.on('-y[NUM]', '
|
107
|
-
opt.on('-m[NUM]', 'Show NUM months.
|
106
|
+
opt.on('-y[NUM]', 'Show NUM years.(0-10)') {|v| options[:years] = v.to_i}
|
107
|
+
opt.on('-m[NUM]', 'Show NUM months.') {|v| options[:months] = v.to_i}
|
108
108
|
opt.on('-e' , 'List with the name of Japanese era.') {|v| options[:era] = v}
|
109
|
+
opt.on('-s', '--size=compact|minimum', ['compact', 'minimum'], 'Set width of monthly calendar.') {|v| options[:size] = v}
|
109
110
|
opt.separator('')
|
110
111
|
opt.on('Example:',
|
111
112
|
' jcal # Show monthly calendar of this month.',
|
@@ -128,6 +129,7 @@ OptionParser.new do |opt|
|
|
128
129
|
end
|
129
130
|
|
130
131
|
# 引数解析
|
132
|
+
monthly_size = {'compact' => 1, 'minimum' => 2}
|
131
133
|
y = ARGV.map(&:to_i).select {|i| i > 12 }
|
132
134
|
m = ARGV.map(&:to_i).select {|i| i <= 12 }
|
133
135
|
m.map! {|i| i == 0 ? Date.today.month : i}
|
@@ -144,5 +146,5 @@ options[:years] ||= (y[1] - y[0]).abs + 1 if y.size == 2 && (options.empty?
|
|
144
146
|
if options.key?(:years) && options[:years] >= 2
|
145
147
|
Jcal::list(y.min, options[:years], options[:era])
|
146
148
|
else
|
147
|
-
Jcal::matrix(y[0], *m)
|
149
|
+
Jcal::matrix(monthly_size[options[:size]].to_i, y[0], *m)
|
148
150
|
end
|
data/lib/jpdate/era.rb
CHANGED
data/lib/jpdate/holiday.rb
CHANGED
@@ -72,6 +72,8 @@ class JPDate < Date
|
|
72
72
|
# 天皇の退位等に関する皇室典範特例法の施行期日を定める政令
|
73
73
|
# 平成30年 2018年 6月20日公布・平成30年 2018年6月20日施行 法律第 55号 国民の祝日に関する法律(改正)
|
74
74
|
# 平成30年 2018年 6月20日公布・平成32年 2020年1月1日施行 法律第 57号 国民の祝日に関する法律(改正)
|
75
|
+
# 平成30年法律第57号による改正後の平成27年法律第33号(平成三十二年東京オリンピック競技大会・東京パラリンピック競技大会特別措置法)
|
76
|
+
# 令和2年法律第68号による改正後の平成27年法律第33号(令和三年東京オリンピック競技大会・東京パラリンピック競技大会特別措置法)
|
75
77
|
{month:1, day:1, term:1949..9999, name:'元旦'},
|
76
78
|
{month:1, day:15, term:1949..1999, name:'成人の日'},
|
77
79
|
{month:1, day:'monday 2', term:2000..9999, name:'成人の日'},
|
@@ -87,17 +89,20 @@ class JPDate < Date
|
|
87
89
|
{month:7, day:20, term:1996..2002, name:'海の日'},
|
88
90
|
{month:7, day:'monday 3', term:2003..2019, name:'海の日'},
|
89
91
|
{month:7, day:23, term:2020..2020, name:'海の日'},
|
90
|
-
{month:7, day:
|
92
|
+
{month:7, day:22, term:2021..2021, name:'海の日'},
|
93
|
+
{month:7, day:'monday 3', term:2022..9999, name:'海の日'},
|
91
94
|
{month:8, day:11, term:2016..2019, name:'山の日'},
|
92
95
|
{month:8, day:10, term:2020..2020, name:'山の日'},
|
93
|
-
{month:8, day:
|
96
|
+
{month:8, day:8, term:2021..2021, name:'山の日'},
|
97
|
+
{month:8, day:11, term:2022..9999, name:'山の日'},
|
94
98
|
{month:9, day:15, term:1966..2002, name:'敬老の日'},
|
95
99
|
{month:9, day:'monday 3', term:2003..9999, name:'敬老の日'},
|
96
100
|
{month:9, day:'autumn_day',term:1948..2099, name:'秋分の日'},
|
97
101
|
{month:10, day:10, term:1966..1999, name:'体育の日'},
|
98
102
|
{month:10, day:'monday 2', term:2000..2019, name:'体育の日'},
|
99
103
|
{month:7, day:24, term:2020..2020, name:'スポーツの日'},
|
100
|
-
{month:
|
104
|
+
{month:7, day:23, term:2021..2021, name:'スポーツの日'},
|
105
|
+
{month:10, day:'monday 2', term:2022..9999, name:'スポーツの日'},
|
101
106
|
{month:11, day:3, term:1948..9999, name:'文化の日'},
|
102
107
|
{month:11, day:23, term:1948..9999, name:'勤労感謝の日'},
|
103
108
|
{month:12, day:23, term:1989..2018, name:'天皇誕生日'},
|
data/lib/jpdate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jpdate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zariganitosh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -76,8 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
|
-
|
80
|
-
rubygems_version: 2.7.8
|
79
|
+
rubygems_version: 3.2.16
|
81
80
|
signing_key:
|
82
81
|
specification_version: 4
|
83
82
|
summary: 日本の祝日を出力するJPDateクラス
|