c-ge-japan_calendar 1.0.0
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.
- data/History.txt +6 -0
- data/Manifest.txt +6 -0
- data/README.txt +57 -0
- data/Rakefile +12 -0
- data/bin/japan_calendar +1 -0
- data/lib/japan_calendar.rb +310 -0
- data/test/test_japan_calendar.rb +152 -0
- metadata +72 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
= japan_calendar
|
2
|
+
|
3
|
+
* http://github.com/c-ge/JapanCalendar
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
���{�̃J�����_�[�N���X�ł��B
|
8
|
+
�N�����w�肷��Ƃ��̌��̏j�Փ����������J�����_�[(JapanCalendar)��Ԃ��܂��B
|
9
|
+
|
10
|
+
== FEATURES/PROBLEMS:
|
11
|
+
|
12
|
+
* none
|
13
|
+
|
14
|
+
== SYNOPSIS:
|
15
|
+
|
16
|
+
require 'japan_calendar'
|
17
|
+
|
18
|
+
jcal = JapanCalendar.new(2009, 5)
|
19
|
+
1.upto(jcal.days) do |day|
|
20
|
+
holidayCount += 1 if jcal.holiday? day
|
21
|
+
workdayCount += 1 if jcal.workday? day
|
22
|
+
puts jcal.holiday_name(day) if jcal.holiday? day
|
23
|
+
end
|
24
|
+
|
25
|
+
== REQUIREMENTS:
|
26
|
+
|
27
|
+
* ruby
|
28
|
+
* gem
|
29
|
+
|
30
|
+
== INSTALL:
|
31
|
+
|
32
|
+
* sudo gem install c-ge-JapanCalendar
|
33
|
+
|
34
|
+
== LICENSE:
|
35
|
+
|
36
|
+
GPLv2
|
37
|
+
|
38
|
+
Copyright (c) 2009 cyberwave
|
39
|
+
|
40
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
41
|
+
a copy of this software and associated documentation files (the
|
42
|
+
'Software'), to deal in the Software without restriction, including
|
43
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
44
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
45
|
+
permit persons to whom the Software is furnished to do so, subject to
|
46
|
+
the following conditions:
|
47
|
+
|
48
|
+
The above copyright notice and this permission notice shall be
|
49
|
+
included in all copies or substantial portions of the Software.
|
50
|
+
|
51
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
52
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
53
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
54
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
55
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
56
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
57
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/japan_calendar
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
#!/
|
@@ -0,0 +1,310 @@
|
|
1
|
+
# = JapanCalender
|
2
|
+
# Author:: 梨木 繁幸(Nashiki Shigeyuki)[http://cyberwave.jp/nashiki/]
|
3
|
+
# Copyright:: Copyright 2009 cyberwave.jp[http://cyberwave.jp/]
|
4
|
+
# License:: GPL v2
|
5
|
+
#
|
6
|
+
# 日本のカレンダークラスです。
|
7
|
+
# 年月を指定するとその月の祝祭日が入ったカレンダー(JapanCalendar)を返します。
|
8
|
+
#
|
9
|
+
# === 使い方
|
10
|
+
# gem install japan_calendar
|
11
|
+
#
|
12
|
+
# === サンプルソース
|
13
|
+
# require 'japan_calendar'
|
14
|
+
#
|
15
|
+
# jcal = JapanCalendar.new(2009, 5)
|
16
|
+
# 1.upto(jcal.days) do |day|
|
17
|
+
# holidayCount += 1 if jcal.holiday? day
|
18
|
+
# workdayCount += 1 if jcal.workday? day
|
19
|
+
# puts jcal.holiday_name(day) if jcal.holiday? day
|
20
|
+
# end
|
21
|
+
|
22
|
+
|
23
|
+
# === JapanCalendarクラスの機能
|
24
|
+
#
|
25
|
+
# 1. その日が、平日かどうか取得できます。
|
26
|
+
# 2. その日が、祝祭日かどうか取得できます。
|
27
|
+
# 3. 祝祭日のとき、日本語名を取得できます。
|
28
|
+
# 4. 土曜日を休日扱いにするかしないか設定できます。
|
29
|
+
# * 初期設定では土曜日は平日扱い
|
30
|
+
|
31
|
+
class JapanCalendar
|
32
|
+
VERSION = '1.0.0'
|
33
|
+
|
34
|
+
attr_reader :year, :month
|
35
|
+
attr_reader :holidays, :workdays, :not_holidays, :days
|
36
|
+
|
37
|
+
# [year]
|
38
|
+
# 年を指定します。
|
39
|
+
# 省略時は、実行時の年になります。
|
40
|
+
# [month]
|
41
|
+
# 月をしてします。
|
42
|
+
# 省略時は、実行時の月になります。
|
43
|
+
# [saturday_holiday_flg]
|
44
|
+
# 土曜日を給仕扱いする場合はTrueを指定します。
|
45
|
+
# False又は省略した時は、法令どおり土曜日は平日扱いになります。
|
46
|
+
def initialize(year = nil, month = nil, saturday_holiday_flg = false)
|
47
|
+
# 土曜日を祝日扱いするかフラグ
|
48
|
+
@saturday_holiday_flg = saturday_holiday_flg
|
49
|
+
|
50
|
+
# 呼び出し日の取得(内部利用)
|
51
|
+
@now = Time.now
|
52
|
+
|
53
|
+
# 取得対象年月(省略時はコール時の年月)
|
54
|
+
@year = if year == nil then @now.year else year end
|
55
|
+
@month = if month == nil then @now.month else month end
|
56
|
+
|
57
|
+
# その月の月末日
|
58
|
+
@days = Date.new(@year, @month, -1).strftime("%d").to_i
|
59
|
+
|
60
|
+
# 日毎の休日フラグ(引数は日)
|
61
|
+
@holiday = []
|
62
|
+
# 日毎の日本語休日名(引数は日)
|
63
|
+
@holiday_name = []
|
64
|
+
|
65
|
+
# 対象月の日毎のTimeオブジェクトを作成(引数は日)
|
66
|
+
@month_time_objs = []
|
67
|
+
1.upto(@days) { |d|
|
68
|
+
@month_time_objs[d] = Time.local(@year, @month, d, 0, 0, 0)
|
69
|
+
@holiday[d] = false
|
70
|
+
}
|
71
|
+
|
72
|
+
holiday_str = <<EOS
|
73
|
+
1 1 0 元旦
|
74
|
+
1 15 -1999 成人の日
|
75
|
+
1 HM2 2000- 成人の日
|
76
|
+
2 11 0 建国記念の日
|
77
|
+
3 SHUNBUN 0 春分の日
|
78
|
+
4 29 -1988 天皇誕生日
|
79
|
+
4 29 1989-2006 みどりの日
|
80
|
+
4 29 2007- 昭和の日
|
81
|
+
5 3 0 憲法記念日
|
82
|
+
5 4 2007- みどりの日
|
83
|
+
5 5 0 こどもの日
|
84
|
+
6 20 1996-2002 海の日
|
85
|
+
6 HM3 2003- 海の日
|
86
|
+
9 15 -2002 敬老の日
|
87
|
+
9 HM3 2003- 敬老の日
|
88
|
+
9 SYUBUN 0 秋分の日
|
89
|
+
10 10 -1999 体育の日
|
90
|
+
10 HM2 2000- 体育の日
|
91
|
+
11 3 0 文化の日
|
92
|
+
11 12 2009 天皇即位20年
|
93
|
+
11 23 0 勤労感謝の日
|
94
|
+
12 23 1989- 天皇誕生日
|
95
|
+
EOS
|
96
|
+
|
97
|
+
holiday_str.split(/\n/).each do |line|
|
98
|
+
next if line == '' or line =~ /^\#/
|
99
|
+
line.sub!(/\#.*$/, '')
|
100
|
+
m, d, y, c = line.split(/\s+/, 4)
|
101
|
+
if y != '0'
|
102
|
+
if y[0,1] == '-'
|
103
|
+
next if @year > y[1,4].to_i
|
104
|
+
elsif y[-1,1] == '-'
|
105
|
+
next if @year < y[0,4].to_i
|
106
|
+
elsif y[4,1] == '-'
|
107
|
+
next if @year < y[0,4].to_i || @year > y[5,4].to_i
|
108
|
+
else
|
109
|
+
next if @year != y.to_i
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
if @month == m.to_i
|
114
|
+
case d
|
115
|
+
when 'SHUNBUN'
|
116
|
+
d = syunbun(@year).to_s
|
117
|
+
when 'SYUBUN'
|
118
|
+
d = syubun(@year).to_s
|
119
|
+
when 'HM2'
|
120
|
+
d = monday_of_week(2).to_s
|
121
|
+
when 'HM3'
|
122
|
+
d = monday_of_week(3).to_s
|
123
|
+
end
|
124
|
+
@holiday[d.to_i] = true
|
125
|
+
@holiday_name[d.to_i] = c
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
if @year >= 1986
|
130
|
+
i = 0
|
131
|
+
while i < 31 - 2
|
132
|
+
# 「国民の休日」判定
|
133
|
+
# 当日が祝日 次の日が祝日でない 次の日が日曜日でない 次の次の日が祝日
|
134
|
+
if @holiday[i] and @holiday[i + 1] == false and @month_time_objs[i + 1].wday != 0 and @holiday[i + 2]
|
135
|
+
@holiday[i + 1] = true
|
136
|
+
@holiday_name[i + 1] = '国民の休日'
|
137
|
+
i += 1 # skip
|
138
|
+
end
|
139
|
+
i += 1
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# 休日の日数カウント
|
144
|
+
@holidays = 0
|
145
|
+
1.upto(@days) { |d|
|
146
|
+
@holidays += 1 if holiday?(d)
|
147
|
+
}
|
148
|
+
@workdays = @days - @holidays
|
149
|
+
@not_holidays = @workdays
|
150
|
+
end
|
151
|
+
|
152
|
+
# [mday]
|
153
|
+
# 日を指定します。(省略不可)
|
154
|
+
#
|
155
|
+
# 休日であればその休日日本語名称を返す
|
156
|
+
# 土曜日はNilを返す
|
157
|
+
def holiday_name mday
|
158
|
+
return @holiday_name[mday]
|
159
|
+
end
|
160
|
+
|
161
|
+
# [mday]
|
162
|
+
# 日を指定します。(省略不可)
|
163
|
+
#
|
164
|
+
# 当日かどうかを返します。
|
165
|
+
def today? mday
|
166
|
+
@now.year == @year and @now.month == @month and @now.mday == mday
|
167
|
+
end
|
168
|
+
|
169
|
+
# [mday]
|
170
|
+
# 日を指定します。(省略不可)
|
171
|
+
#
|
172
|
+
# 平日かどうかを返します。
|
173
|
+
def workday? mday
|
174
|
+
not holiday? mday
|
175
|
+
end
|
176
|
+
|
177
|
+
# [mday]
|
178
|
+
# 日を指定します。(省略不可)
|
179
|
+
#
|
180
|
+
# workday?の別名
|
181
|
+
def not_holiday? mday
|
182
|
+
workday? mday
|
183
|
+
end
|
184
|
+
|
185
|
+
# [mday]
|
186
|
+
# 日を指定します。(省略不可)
|
187
|
+
#
|
188
|
+
# 土日かどうかを返します。
|
189
|
+
def weekend? mday
|
190
|
+
return nil unless @month_time_objs[mday]
|
191
|
+
wday = @month_time_objs[mday].wday
|
192
|
+
return wday == 6 || wday == 0
|
193
|
+
end
|
194
|
+
|
195
|
+
# [mday]
|
196
|
+
# 日を指定します。(省略不可)
|
197
|
+
#
|
198
|
+
# 土曜日かどうかを返します。
|
199
|
+
def saturday? mday
|
200
|
+
return nil unless @month_time_objs[mday]
|
201
|
+
wday = @month_time_objs[mday].wday
|
202
|
+
return wday == 6
|
203
|
+
end
|
204
|
+
|
205
|
+
# [mday]
|
206
|
+
# 日を指定します。(省略不可)
|
207
|
+
#
|
208
|
+
# 日曜日かどうかを返します。
|
209
|
+
def sunday? mday
|
210
|
+
return nil unless @month_time_objs[mday]
|
211
|
+
return true if @holiday[mday]
|
212
|
+
wday = @month_time_objs[mday].wday
|
213
|
+
return wday == 0
|
214
|
+
end
|
215
|
+
|
216
|
+
# [mday]
|
217
|
+
# 日を指定します。(省略不可)
|
218
|
+
#
|
219
|
+
# 休日かどうかを返します。
|
220
|
+
# 土曜日を休日で返すかは、オブジェクト初期化時の土曜日を休日扱いするか否かの設定で決まる。
|
221
|
+
def holiday? mday
|
222
|
+
return nil unless @month_time_objs[mday]
|
223
|
+
return true if @holiday[mday]
|
224
|
+
wday = @month_time_objs[mday].wday
|
225
|
+
|
226
|
+
if (wday == 6 && @saturday_holiday_flg) || wday == 0
|
227
|
+
return true
|
228
|
+
end
|
229
|
+
|
230
|
+
status(mday) == 'holiday'
|
231
|
+
end
|
232
|
+
|
233
|
+
private
|
234
|
+
def status(mday)
|
235
|
+
return nil unless @month_time_objs[mday]
|
236
|
+
return 'holiday' if @holiday[mday]
|
237
|
+
wday = @month_time_objs[mday].wday
|
238
|
+
|
239
|
+
case wday
|
240
|
+
when 1
|
241
|
+
if @month_time_objs[mday].year >= 1973 and mday > 1 and @holiday[mday - 1]
|
242
|
+
# 振替休日
|
243
|
+
'holiday'
|
244
|
+
else
|
245
|
+
'workday'
|
246
|
+
end
|
247
|
+
when 2..5
|
248
|
+
furikae2005(mday, wday)
|
249
|
+
when 0, 6
|
250
|
+
'weekend'
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def wday(mday)
|
255
|
+
return nil unless @month_time_objs[mday]
|
256
|
+
@month_time_objs[mday].wday
|
257
|
+
end
|
258
|
+
|
259
|
+
# 2005 からの振替休日
|
260
|
+
# 連続する祝日が日曜日にかかると祝日の終りの次の平日を振替休日になる
|
261
|
+
def furikae2005(mday, wday)
|
262
|
+
year = @month_time_objs[mday].year
|
263
|
+
if year < 2005
|
264
|
+
return 'workday'
|
265
|
+
end
|
266
|
+
if mday <= wday
|
267
|
+
return 'workday'
|
268
|
+
end
|
269
|
+
(1..wday).each do |i|
|
270
|
+
if @holiday[mday - i] == false
|
271
|
+
return 'workday'
|
272
|
+
end
|
273
|
+
end
|
274
|
+
@holiday_name[mday] = '振替休日'
|
275
|
+
'holiday'
|
276
|
+
end
|
277
|
+
|
278
|
+
def monday_of_week(n)
|
279
|
+
count = 0
|
280
|
+
@month_time_objs.each_index do |d|
|
281
|
+
next if d < 1
|
282
|
+
count += 1 if @month_time_objs[d].wday == 1
|
283
|
+
return d if count == n
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
# 秋分の日
|
288
|
+
def syunbun(year)
|
289
|
+
# (31y+2525)/128-y/4+y/100 (1851年-1999年通用)
|
290
|
+
# (31y+2395)/128-y/4+y/100 (2000年-2150年通用)
|
291
|
+
if year > 2150
|
292
|
+
STDERR.print "over year's: #{year}\n" #'
|
293
|
+
exit 1
|
294
|
+
end
|
295
|
+
v = if year < 2000 then 2213 else 2089 end
|
296
|
+
(31 * year + v)/128 - year/4 + year/100
|
297
|
+
end
|
298
|
+
|
299
|
+
# 春分の日
|
300
|
+
def syubun(year)
|
301
|
+
# (31y+2213)/128-y/4+y/100 (1851年-1999年通用)
|
302
|
+
# (31y+2089)/128-y/4+y/100 (2000年-2150年通用)
|
303
|
+
if year > 2150
|
304
|
+
STDERR.print "over year's: #{year}\n" #'
|
305
|
+
exit 1
|
306
|
+
end
|
307
|
+
v = if year < 2000 then 2525 else 2395 end
|
308
|
+
(31 * year + v)/128 - year/4 + year/100
|
309
|
+
end
|
310
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# To change this template, choose Tools | Templates
|
2
|
+
# and open the template in the editor.
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'japan_calendar'
|
8
|
+
require 'kconv'
|
9
|
+
|
10
|
+
class TestJapanCalendar < Test::Unit::TestCase
|
11
|
+
def setup
|
12
|
+
@now = Time.now
|
13
|
+
@this_year = @now.year
|
14
|
+
@this_month = @now.month
|
15
|
+
@this_day = @now.day
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def test_holiday_workday_flg
|
20
|
+
# 対象年
|
21
|
+
year = 2009
|
22
|
+
|
23
|
+
# 年間カウンター初期化
|
24
|
+
workday_year_count = 0
|
25
|
+
holiday_year_count = 0
|
26
|
+
|
27
|
+
# 週の文字列
|
28
|
+
# 月の配列
|
29
|
+
# 12 か月分の配列
|
30
|
+
1.upto(12) do |month|
|
31
|
+
|
32
|
+
# 初期化
|
33
|
+
workdayCount = 0
|
34
|
+
holidayCount = 0
|
35
|
+
jcal = JapanCalendar.new(year, month, true)
|
36
|
+
|
37
|
+
1.upto(jcal.days) do |day|
|
38
|
+
holidayCount += 1 if jcal.holiday? day
|
39
|
+
workdayCount += 1 if jcal.workday? day
|
40
|
+
end
|
41
|
+
|
42
|
+
# puts "#{year}/#{month} 日数#{workdayCount + holidayCount} 平日#{workdayCount}(時間:#{workdayCount*7.5}) 休日#{holidayCount} 稼働率#{workdayCount * 100 / (workdayCount + holidayCount)}%".tosjis
|
43
|
+
workday_year_count = workday_year_count + workdayCount
|
44
|
+
holiday_year_count = holiday_year_count + holidayCount
|
45
|
+
end
|
46
|
+
|
47
|
+
# puts "年間日数#{workday_year_count + holiday_year_count} 平日#{workday_year_count} 休日#{holiday_year_count} 稼働率#{workday_year_count * 100 / (workday_year_count + holiday_year_count)}%".tosjis
|
48
|
+
|
49
|
+
assert_equal(365, workday_year_count + holiday_year_count)
|
50
|
+
assert_equal(121, holiday_year_count)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_days
|
54
|
+
jcal = JapanCalendar.new(2009, 4)
|
55
|
+
assert_equal 30, jcal.days
|
56
|
+
jcal = JapanCalendar.new(2009, 5)
|
57
|
+
assert_equal 31, jcal.days
|
58
|
+
jcal = JapanCalendar.new(2009, 6)
|
59
|
+
assert_equal 30, jcal.days
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_holiday?
|
63
|
+
jcal = JapanCalendar.new(2009, 5)
|
64
|
+
# 休日以外
|
65
|
+
assert_equal false, jcal.workday?(3)
|
66
|
+
assert_equal false, jcal.not_holiday?(3)
|
67
|
+
# 祝祭日(初期設定では土曜日は平日扱い)
|
68
|
+
assert_equal true, jcal.holiday?(3)
|
69
|
+
|
70
|
+
# 土曜、又は、日曜、確認
|
71
|
+
assert_equal true, jcal.weekend?(3)
|
72
|
+
# 土曜、確認
|
73
|
+
assert_equal false, jcal.saturday?(3)
|
74
|
+
# 日曜、確認
|
75
|
+
assert_equal true, jcal.sunday?(3)
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_saturday_is_holiday
|
79
|
+
# 設定を省略すると、土曜は休日扱いにはなっていない
|
80
|
+
jcal = JapanCalendar.new(2009, 5)
|
81
|
+
assert_equal false, jcal.holiday?(2)
|
82
|
+
|
83
|
+
# 土曜を休日扱いにする
|
84
|
+
jcal = JapanCalendar.new(2009, 5, true)
|
85
|
+
assert_equal true, jcal.holiday?(2)
|
86
|
+
|
87
|
+
# 土曜を休日扱いにしない
|
88
|
+
jcal = JapanCalendar.new(2009, 5, false)
|
89
|
+
assert_equal false, jcal.holiday?(2)
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_days
|
93
|
+
# 土曜日を休日扱いしない
|
94
|
+
jcal = JapanCalendar.new(2009, 5)
|
95
|
+
# 休日
|
96
|
+
assert_equal 8, jcal.holidays
|
97
|
+
# 平日
|
98
|
+
assert_equal 23, jcal.workdays
|
99
|
+
assert_equal 23, jcal.not_holidays
|
100
|
+
# 月末日
|
101
|
+
assert_equal 31, jcal.days
|
102
|
+
|
103
|
+
# 土曜日を休日扱い
|
104
|
+
jcal = JapanCalendar.new(2009, 5, true)
|
105
|
+
# 休日
|
106
|
+
assert_equal 13, jcal.holidays
|
107
|
+
# 平日
|
108
|
+
assert_equal 18, jcal.workdays
|
109
|
+
assert_equal 18, jcal.not_holidays
|
110
|
+
# 月末日
|
111
|
+
assert_equal 31, jcal.days
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_attr_reader
|
115
|
+
jcal = JapanCalendar.new(2009, 5)
|
116
|
+
assert_equal 2009, jcal.year
|
117
|
+
assert_equal 5, jcal.month
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_holiday_name
|
121
|
+
# 2009年4月
|
122
|
+
jcal = JapanCalendar.new(2009, 4)
|
123
|
+
assert_equal '昭和の日', jcal.holiday_name(29)
|
124
|
+
|
125
|
+
# 2009年5月
|
126
|
+
jcal = JapanCalendar.new(2009, 5)
|
127
|
+
assert_equal nil, jcal.holiday_name(2)
|
128
|
+
assert_equal '憲法記念日', jcal.holiday_name(3)
|
129
|
+
assert_equal 'みどりの日', jcal.holiday_name(4)
|
130
|
+
assert_equal 'こどもの日', jcal.holiday_name(5)
|
131
|
+
assert_equal '振替休日', jcal.holiday_name(6)
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_initialize_no_parameter
|
135
|
+
# newの引数が無いと実行時の年月が指定される
|
136
|
+
jcal = JapanCalendar.new
|
137
|
+
assert_equal @this_year, jcal.year
|
138
|
+
assert_equal @this_month, jcal.month
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_today?
|
142
|
+
jcal = JapanCalendar.new
|
143
|
+
1.upto(jcal.days) { |day|
|
144
|
+
if day == @this_day
|
145
|
+
assert_equal true, jcal.today?(day)
|
146
|
+
else
|
147
|
+
assert_equal false, jcal.today?(day)
|
148
|
+
end
|
149
|
+
}
|
150
|
+
|
151
|
+
end
|
152
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: c-ge-japan_calendar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- c-ge
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-13 00:00:00 -07:00
|
13
|
+
default_executable: japan_calendar
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.3.3
|
24
|
+
version:
|
25
|
+
description: "\xE6\x97\xA5\xE6\x9C\xAC\xE3\x81\xAE\xE3\x82\xAB\xE3\x83\xAC\xE3\x83\xB3\xE3\x83\x80\xE3\x83\xBC\xE3\x82\xAF\xE3\x83\xA9\xE3\x82\xB9\xE3\x81\xA7\xE3\x81\x99\xE3\x80\x82\r \xE5\xB9\xB4\xE6\x9C\x88\xE3\x82\x92\xE6\x8C\x87\xE5\xAE\x9A\xE3\x81\x99\xE3\x82\x8B\xE3\x81\xA8\xE3\x81\x9D\xE3\x81\xAE\xE6\x9C\x88\xE3\x81\xAE\xE7\xA5\x9D\xE7\xA5\xAD\xE6\x97\xA5\xE3\x81\x8C\xE5\x85\xA5\xE3\x81\xA3\xE3\x81\x9F\xE3\x82\xAB\xE3\x83\xAC\xE3\x83\xB3\xE3\x83\x80\xE3\x83\xBC(JapanCalendar)\xE3\x82\x92\xE8\xBF\x94\xE3\x81\x97\xE3\x81\xBE\xE3\x81\x99\xE3\x80\x82"
|
26
|
+
email:
|
27
|
+
- nashiki.shigeyuki@cyberwave.jp
|
28
|
+
executables:
|
29
|
+
- japan_calendar
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- README.txt
|
36
|
+
files:
|
37
|
+
- History.txt
|
38
|
+
- Manifest.txt
|
39
|
+
- README.txt
|
40
|
+
- Rakefile
|
41
|
+
- lib/japan_calendar.rb
|
42
|
+
- test/test_japan_calendar.rb
|
43
|
+
has_rdoc: false
|
44
|
+
homepage: http://github.com/c-ge/JapanCalendar
|
45
|
+
licenses:
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options:
|
48
|
+
- --main
|
49
|
+
- README.txt
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
version:
|
64
|
+
requirements: []
|
65
|
+
|
66
|
+
rubyforge_project: japan_calendar
|
67
|
+
rubygems_version: 1.3.5
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: "\xE6\x97\xA5\xE6\x9C\xAC\xE3\x81\xAE\xE3\x82\xAB\xE3\x83\xAC\xE3\x83\xB3\xE3\x83\x80\xE3\x83\xBC\xE3\x82\xAF\xE3\x83\xA9\xE3\x82\xB9\xE3\x81\xA7\xE3\x81\x99\xE3\x80\x82\r \xE5\xB9\xB4\xE6\x9C\x88\xE3\x82\x92\xE6\x8C\x87\xE5\xAE\x9A\xE3\x81\x99\xE3\x82\x8B\xE3\x81\xA8\xE3\x81\x9D\xE3\x81\xAE\xE6\x9C\x88\xE3\x81\xAE\xE7\xA5\x9D\xE7\xA5\xAD\xE6\x97\xA5\xE3\x81\x8C\xE5\x85\xA5\xE3\x81\xA3\xE3\x81\x9F\xE3\x82\xAB\xE3\x83\xAC\xE3\x83\xB3\xE3\x83\x80\xE3\x83\xBC(JapanCalendar)\xE3\x82\x92\xE8\xBF\x94\xE3\x81\x97\xE3\x81\xBE\xE3\x81\x99\xE3\x80\x82"
|
71
|
+
test_files:
|
72
|
+
- test/test_japan_calendar.rb
|