cal-jp-holiday 1.1.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 +15 -0
- data/License.txt +20 -0
- data/Manifest.txt +25 -0
- data/README.txt +84 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +72 -0
- data/config/requirements.rb +17 -0
- data/lib/calendar-japanese-holiday.rb +5 -0
- data/lib/calendar-japanese-holiday/version.rb +9 -0
- data/lib/calendar/japanese/holiday.rb +394 -0
- data/log/debug.log +0 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_calendar-japanese-holiday.rb +83 -0
- data/test/test_helper.rb +2 -0
- data/website/index.html +93 -0
- data/website/index.txt +39 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +76 -0
data/History.txt
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
== 1.1.0 2008-01-05
|
|
2
|
+
|
|
3
|
+
* 4 minor enhancement
|
|
4
|
+
* �j���������菈���lj��iwday �������Ȃ��I�u�W�F�N�g�ɂ� mix-in �\�ɂ����j
|
|
5
|
+
* �����R�[�h�������菈���E�w��@�\�lj�
|
|
6
|
+
* �h�L�������e�[�V�����R�����g�lj�
|
|
7
|
+
* ���W���[������ JapaneseHolidays ���� Calendar::Japanese::Holiday �ɕύX
|
|
8
|
+
|
|
9
|
+
* 1 bug fix
|
|
10
|
+
* �U��ւ��x�������݂��Ȃ��N�ɂ��U��ւ��x�������݂��Ă��܂��o�O���C��
|
|
11
|
+
|
|
12
|
+
== 1.0.0 2007-11-15
|
|
13
|
+
|
|
14
|
+
* 1 major enhancement:
|
|
15
|
+
* �V�K�쐬
|
data/License.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2007-2008 yy
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
History.txt
|
|
2
|
+
License.txt
|
|
3
|
+
Manifest.txt
|
|
4
|
+
README.txt
|
|
5
|
+
Rakefile
|
|
6
|
+
config/hoe.rb
|
|
7
|
+
config/requirements.rb
|
|
8
|
+
lib/calendar-japanese-holiday.rb
|
|
9
|
+
lib/calendar-japanese-holiday/version.rb
|
|
10
|
+
lib/calendar/japanese/holiday.rb
|
|
11
|
+
log/debug.log
|
|
12
|
+
script/destroy
|
|
13
|
+
script/generate
|
|
14
|
+
script/txt2html
|
|
15
|
+
setup.rb
|
|
16
|
+
tasks/deployment.rake
|
|
17
|
+
tasks/environment.rake
|
|
18
|
+
tasks/website.rake
|
|
19
|
+
test/test_calendar-japanese-holiday.rb
|
|
20
|
+
test/test_helper.rb
|
|
21
|
+
website/index.html
|
|
22
|
+
website/index.txt
|
|
23
|
+
website/javascripts/rounded_corners_lite.inc.js
|
|
24
|
+
website/stylesheets/screen.css
|
|
25
|
+
website/template.rhtml
|
data/README.txt
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
= Calendar::Japanese::Holiday
|
|
2
|
+
|
|
3
|
+
Author:: yy <http://dishhh.jp/>
|
|
4
|
+
Version:: 1.1
|
|
5
|
+
License:: MIT
|
|
6
|
+
|
|
7
|
+
== Description
|
|
8
|
+
���{�̏j�����������W���[���B
|
|
9
|
+
|
|
10
|
+
Date�ATime�ADateTime �N���X�� Calendar::Japanese::Holiday ���W���[���� Mix-in ���邱�ƂŁA
|
|
11
|
+
���{�̏j�������擾����@�\���lj������B
|
|
12
|
+
Date�ATime�ADateTime �ȊO�̃N���X�ł����Ă� year�Amonth�Aday �����N���X�ł���Η��p���邱�Ƃ��ł���B
|
|
13
|
+
|
|
14
|
+
# �x�����ǂ�����Ԃ�
|
|
15
|
+
date.holiday?
|
|
16
|
+
|
|
17
|
+
# �j���̖��O��Ԃ�
|
|
18
|
+
date.holiday
|
|
19
|
+
|
|
20
|
+
# �y�����ǂ�����Ԃ�
|
|
21
|
+
date.weekend?
|
|
22
|
+
|
|
23
|
+
# �j�����ǂ�����Ԃ�
|
|
24
|
+
date.national_holiday?
|
|
25
|
+
|
|
26
|
+
# �U�x�����ǂ�����Ԃ�
|
|
27
|
+
date.substitute_holiday?
|
|
28
|
+
|
|
29
|
+
Holiday#holiday?() ���\�b�h�́uweekend? or national_holiday? or substitute_holiday?�v�Ɠ����B
|
|
30
|
+
���̂��ߏj���݂̂肵�����ꍇ�� national_holiday?() �� substitute_holiday?() ���\�b�h���g�p����B
|
|
31
|
+
|
|
32
|
+
Holiday#holiday() ���\�b�h�Ŏ擾�����j�����͓��{��}���`�o�C�g���������A
|
|
33
|
+
�g�p����镶���R�[�h�̓v���b�g�t�H�[���ɉ����Ď����I�ɑI�������B
|
|
34
|
+
��������ɕ����R�[�h���擾�ł��Ȃ��ꍇ�́A
|
|
35
|
+
Holiday.set_nkf_opts() ���\�b�h��p���Ė����I�ɕ����R�[�h���w�肷�邱�Ƃ��ł���B
|
|
36
|
+
|
|
37
|
+
���̃X�N���v�g�͎R�{�Ă���́u�j���Ή��J�����_�[�v���x�[�X�ɂ��Ă��܂��B
|
|
38
|
+
|
|
39
|
+
[�u�j���Ή��J�����_�[�v]
|
|
40
|
+
http://itdict.ddo.jp/~yamamoto/Script/Calendar/
|
|
41
|
+
|
|
42
|
+
== Install
|
|
43
|
+
|
|
44
|
+
=== gem
|
|
45
|
+
|
|
46
|
+
sudo gem install calendar-japanese-holiday
|
|
47
|
+
|
|
48
|
+
=== svn
|
|
49
|
+
|
|
50
|
+
svn co svn://rubyforge.org/var/svn/calendar-japanese-holiday/trunk ./
|
|
51
|
+
|
|
52
|
+
=== tgz
|
|
53
|
+
|
|
54
|
+
download: http://rubyforge.org/projects/calendar-japanese-holiday
|
|
55
|
+
|
|
56
|
+
== Sample
|
|
57
|
+
|
|
58
|
+
=== case 1
|
|
59
|
+
require 'calendar/japanese/holiday'
|
|
60
|
+
require 'date'
|
|
61
|
+
|
|
62
|
+
# Date �N���X�� Mix-in ����
|
|
63
|
+
class Date
|
|
64
|
+
include Calendar::Japanese::Holiday
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
today = Date.today
|
|
68
|
+
if today.national_holiday?
|
|
69
|
+
puts today.holiday
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
=== case 2
|
|
73
|
+
# Time �I�u�W�F�N�g�� Mix-in ����
|
|
74
|
+
puts Time.now.extend(Calendar::Japanese::Holiday).holiday
|
|
75
|
+
|
|
76
|
+
=== case 3
|
|
77
|
+
# Mix-in �����ɗ��p���� (deprecated)
|
|
78
|
+
holiday = Calendar::Japanese::Holiday.holiday_info Time.now
|
|
79
|
+
puts holiday.name if info.is_national
|
|
80
|
+
|
|
81
|
+
=== case 4
|
|
82
|
+
# �����R�[�h�������I�� EUC �Ɏw�肷��
|
|
83
|
+
Calendar::Japanese::Holiday.set_opts "-e"
|
|
84
|
+
puts Date.parse("2008-01-01").extend(Calendar::Japanese::Holiday).holiday
|
data/Rakefile
ADDED
data/config/hoe.rb
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require 'calendar-japanese-holiday/version'
|
|
2
|
+
|
|
3
|
+
AUTHOR = 'yy'
|
|
4
|
+
EMAIL = "dishhh@gmail.com"
|
|
5
|
+
DESCRIPTION = "module for Japanese holiday"
|
|
6
|
+
GEM_NAME = 'cal-jp-holiday' # what ppl will type to install your gem
|
|
7
|
+
RUBYFORGE_PROJECT = 'cal-jp-holiday' # The unix name for your project
|
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
|
10
|
+
|
|
11
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
|
12
|
+
@config = nil
|
|
13
|
+
RUBYFORGE_USERNAME = "unknown"
|
|
14
|
+
def rubyforge_username
|
|
15
|
+
unless @config
|
|
16
|
+
begin
|
|
17
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
|
18
|
+
rescue
|
|
19
|
+
puts <<-EOS
|
|
20
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
|
21
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
|
22
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
|
23
|
+
EOS
|
|
24
|
+
exit
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
REV = nil
|
|
32
|
+
# UNCOMMENT IF REQUIRED:
|
|
33
|
+
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
|
34
|
+
VERS = CalendarJapaneseHoliday::VERSION::STRING + (REV ? ".#{REV}" : "")
|
|
35
|
+
RDOC_OPTS = ['--quiet', '--title', 'calendar-japanese-holiday documentation',
|
|
36
|
+
"--opname", "index.html",
|
|
37
|
+
"--line-numbers",
|
|
38
|
+
"--main", "README",
|
|
39
|
+
"--inline-source",
|
|
40
|
+
"--charset=Shift_JIS"]
|
|
41
|
+
|
|
42
|
+
class Hoe
|
|
43
|
+
def extra_deps
|
|
44
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
|
45
|
+
@extra_deps
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Generate all the Rake tasks
|
|
50
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
|
51
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
52
|
+
p.author = AUTHOR
|
|
53
|
+
p.description = DESCRIPTION
|
|
54
|
+
p.email = EMAIL
|
|
55
|
+
p.summary = DESCRIPTION
|
|
56
|
+
p.url = HOMEPATH
|
|
57
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
|
58
|
+
p.test_globs = ["test/**/test_*.rb"]
|
|
59
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
|
60
|
+
|
|
61
|
+
# == Optional
|
|
62
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
|
63
|
+
#p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
|
64
|
+
|
|
65
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
|
70
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
|
71
|
+
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
|
72
|
+
hoe.rsync_args = '-av --delete --ignore-errors'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
include FileUtils
|
|
3
|
+
|
|
4
|
+
require 'rubygems'
|
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
|
6
|
+
begin
|
|
7
|
+
require req_gem
|
|
8
|
+
rescue LoadError
|
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
|
11
|
+
exit
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
|
16
|
+
|
|
17
|
+
require 'calendar-japanese-holiday'
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
# calendar/japanese/holiday.rb
|
|
2
|
+
|
|
3
|
+
require 'nkf'
|
|
4
|
+
|
|
5
|
+
# ���[�e�B���e�B�Q
|
|
6
|
+
module Util
|
|
7
|
+
# ���t����̃��[�e�B���e�B
|
|
8
|
+
module DateTimeUtil
|
|
9
|
+
# +a+ �� +b+ ���������t���ǂ�����
|
|
10
|
+
def DateTimeUtil.equals_date(a, b)
|
|
11
|
+
return (a.year == b.year and a.month == b.month and a.day == b.day)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# �j�����Z�o����
|
|
15
|
+
# Since:: 1.1
|
|
16
|
+
def DateTimeUtil.wday(date)
|
|
17
|
+
return date.wday if defined?(date.wday)
|
|
18
|
+
# Zeller(�c�F���[)�̌��� 1583�N����3999�N�܂�
|
|
19
|
+
year = date.year
|
|
20
|
+
month = date.month
|
|
21
|
+
day = date.day
|
|
22
|
+
# raise "year 1583-3999 [#{year}]" if year < 1583 or year > 3999
|
|
23
|
+
if month == 1 or month == 2
|
|
24
|
+
month += 12
|
|
25
|
+
year -= 1
|
|
26
|
+
end
|
|
27
|
+
# ������㉺���ɕ���
|
|
28
|
+
head = (year / 100).to_i
|
|
29
|
+
tail = year - 100 * head
|
|
30
|
+
return ((head / 4).to_i - 2 * head + tail + (tail / 4).to_i + (2.6 * (month + 1)).to_i + day - 1) % 7
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# �v���b�g�t�H�[���Ɋւ��郆�[�e�B���e�B
|
|
35
|
+
# Since:: 1.1
|
|
36
|
+
module PlatformUtil
|
|
37
|
+
@@charcode = nil
|
|
38
|
+
|
|
39
|
+
# �l�C�e�B�u�̕����R�[�h�肷��
|
|
40
|
+
# Warning:: ���̃��\�b�h�̃��W�b�N�͂т����肷�邭�炢�K���ł�
|
|
41
|
+
def PlatformUtil.default_charcode
|
|
42
|
+
return @@charcode unless @@charcode.nil?
|
|
43
|
+
@@charcode = "euc"
|
|
44
|
+
if /win32|cygwin|mingw|darwin|hpux|aix|bccwin/ =~ RUBY_PLATFORM
|
|
45
|
+
@@charcode = "sjis"
|
|
46
|
+
end
|
|
47
|
+
return @@charcode
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
module Calendar
|
|
53
|
+
module Japanese
|
|
54
|
+
|
|
55
|
+
# ���{�̏j�����������W���[��
|
|
56
|
+
module Holiday
|
|
57
|
+
# �x�����I�u�W�F�N�g
|
|
58
|
+
class HolidayInfo
|
|
59
|
+
def initialize(date)
|
|
60
|
+
@date = date
|
|
61
|
+
@is_national = false
|
|
62
|
+
@name = ""
|
|
63
|
+
@is_substitute = false
|
|
64
|
+
end
|
|
65
|
+
# ���t�I�u�W�F�N�g
|
|
66
|
+
attr_accessor :date
|
|
67
|
+
# �j�����ǂ���
|
|
68
|
+
attr_accessor :is_national
|
|
69
|
+
# �j����
|
|
70
|
+
attr_accessor :name
|
|
71
|
+
# �U�x�����ǂ���
|
|
72
|
+
attr_accessor :is_substitute
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# ���t +date+ �Ɋւ���j�����I�u�W�F�N�g (HolidayInfo) ���擾����
|
|
76
|
+
def Holiday.holiday_info(date)
|
|
77
|
+
holiday_info = Holiday.national_holiday_info(date)
|
|
78
|
+
if !holiday_info.is_national
|
|
79
|
+
holiday_info.is_substitute = Holiday.check_substitute_holiday(date)
|
|
80
|
+
end
|
|
81
|
+
return holiday_info
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# �x�����ǂ�����Ԃ�
|
|
85
|
+
def holiday?
|
|
86
|
+
return (weekend? or national_holiday? or substitute_holiday?)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# �j������Ԃ�
|
|
90
|
+
def holiday
|
|
91
|
+
return get_holiday_info.name
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# �y�����ǂ�����Ԃ�
|
|
95
|
+
def weekend?
|
|
96
|
+
weekday = Util::DateTimeUtil.wday(self)
|
|
97
|
+
return (weekday == 0 or weekday == 6)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# �����̏j�����ǂ�����Ԃ�
|
|
101
|
+
def national_holiday?
|
|
102
|
+
return get_holiday_info.is_national
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# �U��ւ��x�����ǂ�����Ԃ�
|
|
106
|
+
def substitute_holiday?
|
|
107
|
+
return get_holiday_info.is_substitute
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# NKF �̎��s�I�v�V������ݒ肷��
|
|
111
|
+
# Since:: 1.1
|
|
112
|
+
def Holiday.set_nkf_opts opts
|
|
113
|
+
@@nkf_opts = opts
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
private
|
|
117
|
+
|
|
118
|
+
# NKF �̎��s�I�v�V����
|
|
119
|
+
@@nkf_opts = nil
|
|
120
|
+
|
|
121
|
+
# NKF �̎��s�I�v�V������Ԃ�
|
|
122
|
+
def nkf_opts
|
|
123
|
+
unless @@nkf_opts.nil?
|
|
124
|
+
@@nkf_opts = "" if @@nkf_opts == "-s"
|
|
125
|
+
return @@nkf_opts
|
|
126
|
+
end
|
|
127
|
+
if "euc" == Util::PlatformUtil.default_charcode
|
|
128
|
+
@@nkf_opts = "-e"
|
|
129
|
+
else
|
|
130
|
+
@@nkf_opts = ""
|
|
131
|
+
end
|
|
132
|
+
return @@nkf_opts
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# str ��K�ȕ����R�[�h�ɕϊ����ĕԂ�
|
|
136
|
+
def get_nkf_text str
|
|
137
|
+
if !str.empty? and !nkf_opts.empty?
|
|
138
|
+
return NKF.nkf("-S #{nkf_opts}", str)
|
|
139
|
+
end
|
|
140
|
+
return str
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# date ���獑���̏j����ݒ肳�ꂽ HolidayInfo �I�u�W�F�N�g������
|
|
144
|
+
def Holiday.national_holiday_info(date)
|
|
145
|
+
info = HolidayInfo.new(date)
|
|
146
|
+
case date.month
|
|
147
|
+
when 1
|
|
148
|
+
if date.year <= 1948
|
|
149
|
+
if date.day == 3
|
|
150
|
+
info.name = "���n��"
|
|
151
|
+
elsif date.day == 5
|
|
152
|
+
info.name = "�V�N����"
|
|
153
|
+
elsif date.year < 1913 and date.day == 30
|
|
154
|
+
info.name = "�F���V�c��"
|
|
155
|
+
end
|
|
156
|
+
elsif date.year < 2000
|
|
157
|
+
if date.day == 1
|
|
158
|
+
info.name = "����"
|
|
159
|
+
elsif date.day == 15
|
|
160
|
+
info.name = "���l�̓�"
|
|
161
|
+
end
|
|
162
|
+
else
|
|
163
|
+
if date.day == 1
|
|
164
|
+
info.name = "����"
|
|
165
|
+
elsif date.day >= 8 and date.day <= 14 and Util::DateTimeUtil.wday(date) == 1 and date.year > 1999
|
|
166
|
+
info.name = "���l�̓�"
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
when 2
|
|
170
|
+
if date.year <= 1948
|
|
171
|
+
if date.day == 11
|
|
172
|
+
info.name = "�I����"
|
|
173
|
+
end
|
|
174
|
+
elsif date.year > 1966
|
|
175
|
+
if date.day == 11
|
|
176
|
+
info.name = "�����L�O�̓�"
|
|
177
|
+
elsif date.year == 1989
|
|
178
|
+
if date.day == 24
|
|
179
|
+
info.name = "��r�̗�"
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
when 3
|
|
184
|
+
if date.year <= 1948
|
|
185
|
+
if date.year >= 1900 and date.day == (date.year * 0.24242 - date.year / 4 + 35.84).to_i
|
|
186
|
+
info.name = "�t�G�c�ˍ�"
|
|
187
|
+
end
|
|
188
|
+
else
|
|
189
|
+
if date.year <= 2099 and date.day == (date.year * 0.24242 - date.year / 4 + 35.84).to_i
|
|
190
|
+
info.name = "�t���̓�"
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
when 4
|
|
194
|
+
if date.year <= 1948
|
|
195
|
+
if date.day == 3
|
|
196
|
+
info.name = "�_���V�c��"
|
|
197
|
+
elsif date.day == 29 and date.year > 1926
|
|
198
|
+
info.name = "�V����"
|
|
199
|
+
end
|
|
200
|
+
elsif date.year == 1959 and date.day == 10
|
|
201
|
+
info.name = "���m�e�������̋V"
|
|
202
|
+
elsif date.year < 1989
|
|
203
|
+
info.name = "�V�c�a����" if date.day == 29
|
|
204
|
+
elsif date.year < 2007
|
|
205
|
+
info.name = "�݂ǂ�̓�" if date.day == 29
|
|
206
|
+
else
|
|
207
|
+
info.name = "���a�̓�" if date.day == 29
|
|
208
|
+
end
|
|
209
|
+
when 5
|
|
210
|
+
if date.year > 1948
|
|
211
|
+
if date.day == 3
|
|
212
|
+
info.name = "���@�L�O��"
|
|
213
|
+
elsif date.day == 5
|
|
214
|
+
info.name = "���ǂ��̓�"
|
|
215
|
+
end
|
|
216
|
+
if date.year < 2007
|
|
217
|
+
if date.year > 1985 and date.day == 4 and Util::DateTimeUtil.wday(date) > 1
|
|
218
|
+
info.name = "�����̋x��"
|
|
219
|
+
end
|
|
220
|
+
else
|
|
221
|
+
info.name = "�݂ǂ�̓�" if date.day == 4
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
when 6
|
|
225
|
+
if date.day == 9 and date.year == 1993
|
|
226
|
+
info.name = "���m�e�������̋V"
|
|
227
|
+
end
|
|
228
|
+
when 7
|
|
229
|
+
if date.year < 1926 and date.year > 1912
|
|
230
|
+
if date.day == 30
|
|
231
|
+
info.name = "�����V�c��"
|
|
232
|
+
end
|
|
233
|
+
elsif date.year > 1995
|
|
234
|
+
if date.year < 2003
|
|
235
|
+
info.name = "�C�̓�" if date.day == 20
|
|
236
|
+
elsif date.day >= 15 and date.day <= 21 and Util::DateTimeUtil.wday(date) == 1
|
|
237
|
+
info.name = "�C�̓�"
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
when 8
|
|
241
|
+
if date.year < 1926 and date.year > 1912
|
|
242
|
+
if date.day == 31
|
|
243
|
+
info.name = "�V����"
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
when 9
|
|
247
|
+
if date.year < 1948
|
|
248
|
+
if date.year < 1879 and date.day == 17
|
|
249
|
+
info.name = "�_����"
|
|
250
|
+
elsif date.year >= 1900 and date.day == (date.year * 0.24204 - date.year / 4 + 39.01).to_i
|
|
251
|
+
info.name = "�H�G�c�ˍ�"
|
|
252
|
+
end
|
|
253
|
+
else
|
|
254
|
+
if date.year <= 2099 and date.day == (date.year * 0.24204 - date.year / 4 + 39.01).to_i
|
|
255
|
+
info.name = "�H���̓�"
|
|
256
|
+
elsif date.year > 1965
|
|
257
|
+
if date.year < 2003
|
|
258
|
+
info.name = "�h�V�̓�" if date.day == 15
|
|
259
|
+
elsif date.day >= 15 and date.day <= 21 and Util::DateTimeUtil.wday(date) == 1
|
|
260
|
+
info.name = "�h�V�̓�"
|
|
261
|
+
elsif date.day >= 16 and date.day <= 22 and Util::DateTimeUtil.wday(date) == 2 and
|
|
262
|
+
date.year <= 2099 and (date.day + 1) == (date.year * 0.24204 - date.year / 4 + 39.01).to_i
|
|
263
|
+
info.name = "�����̋x��"
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
when 10
|
|
268
|
+
if date.year <= 1947
|
|
269
|
+
if date.year >= 1879 and date.day == 17
|
|
270
|
+
info.name = "�_����"
|
|
271
|
+
elsif date.year < 1927 and date.year > 1912
|
|
272
|
+
info.name = "�V���ߏj��" if date.day == 31
|
|
273
|
+
end
|
|
274
|
+
elsif date.year > 1965
|
|
275
|
+
if date.year < 2000
|
|
276
|
+
if date.day == 10
|
|
277
|
+
info.name = "�̈�̓�"
|
|
278
|
+
end
|
|
279
|
+
else
|
|
280
|
+
if date.day >= 8 and date.day <= 14 and Util::DateTimeUtil.wday(date) == 1
|
|
281
|
+
info.name = "�̈�̓�"
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
when 11
|
|
286
|
+
if date.year <= 1947
|
|
287
|
+
if date.day == 23
|
|
288
|
+
info.name = "�V����"
|
|
289
|
+
elsif date.year == 1915
|
|
290
|
+
case date.day
|
|
291
|
+
when 10
|
|
292
|
+
info.name = "���ʃm�X"
|
|
293
|
+
when 14
|
|
294
|
+
info.name = "�另��"
|
|
295
|
+
when 16
|
|
296
|
+
info.name = "�����X�y�另�Ռ�������"
|
|
297
|
+
end
|
|
298
|
+
elsif date.year < 1912
|
|
299
|
+
info.name = "�V����" if date.day == 3
|
|
300
|
+
elsif date.year > 1926
|
|
301
|
+
if date.year == 1928
|
|
302
|
+
case date.day
|
|
303
|
+
when 10
|
|
304
|
+
info.name = "���ʃm�X"
|
|
305
|
+
when 14
|
|
306
|
+
info.name = "�另��"
|
|
307
|
+
when 16
|
|
308
|
+
info.name = "�����X�y�另�Ռ�������"
|
|
309
|
+
end
|
|
310
|
+
else
|
|
311
|
+
info.name = "������" if date.day == 3
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
else
|
|
315
|
+
if date.day == 3
|
|
316
|
+
info.name = "�����̓�"
|
|
317
|
+
elsif date.day == 23
|
|
318
|
+
info.name = "�ΘJ���ӂ̓�"
|
|
319
|
+
elsif date.day == 12 and date.year == 1990
|
|
320
|
+
info.name = "���ʗ琳�a�̋V"
|
|
321
|
+
end
|
|
322
|
+
end
|
|
323
|
+
when 12
|
|
324
|
+
if date.year <= 1947
|
|
325
|
+
if date.year > 1926
|
|
326
|
+
if date.day == 25
|
|
327
|
+
info.name = "�吳�V�c��"
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
elsif date.year > 1988
|
|
331
|
+
if date.day == 23
|
|
332
|
+
info.name = "�V�c�a����"
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
else
|
|
336
|
+
end
|
|
337
|
+
info.is_national = !info.name.empty?
|
|
338
|
+
return info
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
# date ���U�x�����ǂ����肷��
|
|
342
|
+
def Holiday.check_substitute_holiday(date)
|
|
343
|
+
if Util::DateTimeUtil.wday(date) == 0 or Util::DateTimeUtil.wday(date) == 6
|
|
344
|
+
return false
|
|
345
|
+
end
|
|
346
|
+
if (date.year < 1973 or (date.year == 1973 and date.month < 3))
|
|
347
|
+
return false
|
|
348
|
+
end
|
|
349
|
+
substitute = false
|
|
350
|
+
a_date = date
|
|
351
|
+
loop do
|
|
352
|
+
unless Holiday.national_holiday_info(a_date - 1).is_national
|
|
353
|
+
break
|
|
354
|
+
end
|
|
355
|
+
if Util::DateTimeUtil.wday(a_date - 1) == 0
|
|
356
|
+
substitute = true
|
|
357
|
+
break
|
|
358
|
+
end
|
|
359
|
+
a_date -= 1
|
|
360
|
+
break if date.year < 2007
|
|
361
|
+
end
|
|
362
|
+
return substitute
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
# �x�������擾����
|
|
366
|
+
def get_holiday_info
|
|
367
|
+
if @holiday_info.nil? or !Util::DateTimeUtil.equals_date(self, @holiday_info.date)
|
|
368
|
+
@holiday_info = Holiday.holiday_info(self)
|
|
369
|
+
@holiday_info.name = get_nkf_text(@holiday_info.name)
|
|
370
|
+
end
|
|
371
|
+
return @holiday_info
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
end # class Holiday
|
|
375
|
+
end # module Japanese
|
|
376
|
+
end # module Calendar
|
|
377
|
+
|
|
378
|
+
#require 'date'
|
|
379
|
+
#
|
|
380
|
+
#class Date
|
|
381
|
+
# include Calendar::Japanese::Holiday
|
|
382
|
+
#end
|
|
383
|
+
#
|
|
384
|
+
#class DateTime
|
|
385
|
+
# include Calendar::Japanese::Holiday
|
|
386
|
+
#end
|
|
387
|
+
#
|
|
388
|
+
#class Time
|
|
389
|
+
# include Calendar::Japanese::Holiday
|
|
390
|
+
#end
|
|
391
|
+
#
|
|
392
|
+
#if $0 == __FILE__
|
|
393
|
+
# puts Time.now.extend(Calendar::Japanese::Holiday).holiday
|
|
394
|
+
#end
|