Module: Holidays::JP

Defined in:
lib/generated_definitions/jp.rb

Overview

This file is generated by the Ruby Holidays gem.

Definitions loaded: definitions/jp.yaml

All the definitions are available at github.com/holidays/holidays

Class Method Summary collapse

Class Method Details

.custom_methodsObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/generated_definitions/jp.rb', line 68

def self.custom_methods
  {
      "jp_health_sports_day_substitute(year)" => Proc.new { |year|
Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, 10, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 2, 1))
},

"jp_vernal_equinox_day(year)" => Proc.new { |year|
day =
  case year
  when 1851..1899
19.8277
  when 1900..1979
20.8357
  when 1980..2099
20.8431
  when 2100..2150
21.8510
  else
raise IndexError.new("Out of range")
  end
day += 0.242194 * (year - 1980) - ((year - 1980)/4).floor
day = day.floor
Date.civil(year, 3, day)
},

"jp_vernal_equinox_day_substitute(year)" => Proc.new { |year|
date = Holidays::Factory::Definition.custom_methods_repository.find("jp_vernal_equinox_day(year)").call(year)
Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, date.month, date.mday)
},

"jp_marine_day_substitute(year)" => Proc.new { |year|
Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, 7, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 7, 3, 1))
},

"jp_national_culture_day(year)" => Proc.new { |year|
day =
  case year
  when 1851..1899
22.2588
  when 1900..1979
23.2588
  when 1980..2099
23.2488
  when 2100..2150
24.2488
  else
raise IndexError.new("Out of range")
  end
day += 0.242194 * (year - 1980) - ((year - 1980)/4).floor
day = day.floor
Date.civil(year, 9, day)
},

"jp_national_culture_day_substitute(year)" => Proc.new { |year|
date = Holidays::Factory::Definition.custom_methods_repository.find("jp_national_culture_day(year)").call(year)
Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, date.month, date.mday)
},

"jp_citizens_holiday(year)" => Proc.new { |year|
ncd = Holidays::Factory::Definition.custom_methods_repository.find("jp_national_culture_day(year)").call(year)
if ncd.wday == 3
  ncd - 1
else
  nil
end
},

"jp_mountain_holiday(year)" => Proc.new { |year|
Date.civil(year, 8, 11)
},

"jp_mountain_holiday_substitute(year)" => Proc.new { |year|
date = Holidays::Factory::Definition.custom_methods_repository.find("jp_mountain_holiday(year)").call(year)
Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, date.month, date.mday)
},

"jp_respect_for_aged_holiday_substitute(year)" => Proc.new { |year|
Holidays::Factory::Definition.custom_methods_repository.find("jp_substitute_holiday(year, month, day)").call(year, 9, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 9, 3, 1))
},

"jp_substitute_holiday(year, month, day)" => Proc.new { |year, month, day|
date = Date.civil(year, month, day)
date.wday == 0 ? (Holidays::Factory::Definition.custom_methods_repository.find("jp_next_weekday(date)").call(date+1)) : nil
},

"jp_next_weekday(date)" => Proc.new { |date|
# This suuuucks. I have no idea how to make this not reach into our interal ruby API to do this.
# I'm punting, I'll come back to this.
is_holiday = Holidays::JP.holidays_by_month[date.month].any? do |holiday|
  holiday[:mday] == date.day
end
date.wday == 0 || is_holiday ? (Holidays::Factory::Definition.custom_methods_repository.find("jp_next_weekday(date)").call(date+1)) : date
},


  }
end

.defined_regionsObject

:nodoc:



9
10
11
# File 'lib/generated_definitions/jp.rb', line 9

def self.defined_regions
  [:jp]
end

.holidays_by_monthObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/generated_definitions/jp.rb', line 13

def self.holidays_by_month
  {
            1 => [{:mday => 1, :name => "元日", :regions => [:jp]},
        {:wday => 1, :week => 2, :name => "成人の日", :regions => [:jp]},
        {:mday => 1, :function => "jp_substitute_holiday(year, month, day)", :function_arguments => [:year, :month, :day], :name => "振替休日", :regions => [:jp]}],
  2 => [{:mday => 11, :name => "建国記念の日", :regions => [:jp]},
        {:mday => 11, :function => "jp_substitute_holiday(year, month, day)", :function_arguments => [:year, :month, :day], :name => "振替休日", :regions => [:jp]},
        {:mday => 23, :year_ranges => { :from => 2020 },:name => "天皇誕生日", :regions => [:jp]},
        {:mday => 23, :function => "jp_substitute_holiday(year, month, day)", :function_arguments => [:year, :month, :day], :year_ranges => { :from => 2020 },:name => "振替休日", :regions => [:jp]}],
  3 => [{:function => "jp_vernal_equinox_day(year)", :function_arguments => [:year], :name => "春分の日", :regions => [:jp]},
        {:function => "jp_vernal_equinox_day_substitute(year)", :function_arguments => [:year], :name => "振替休日", :regions => [:jp]}],
  4 => [{:mday => 29, :name => "昭和の日", :regions => [:jp]},
        {:mday => 29, :function => "jp_substitute_holiday(year, month, day)", :function_arguments => [:year, :month, :day], :name => "振替休日", :regions => [:jp]},
        {:mday => 30, :year_ranges => { :limited => [2019] },:name => "休日", :regions => [:jp]}],
  5 => [{:mday => 1, :year_ranges => { :limited => [2019] },:name => "天皇即位", :regions => [:jp]},
        {:mday => 2, :year_ranges => { :limited => [2019] },:name => "休日", :regions => [:jp]},
        {:mday => 3, :name => "憲法記念日", :regions => [:jp]},
        {:mday => 4, :name => "みどりの日", :regions => [:jp]},
        {:mday => 5, :name => "こどもの日", :regions => [:jp]},
        {:mday => 3, :function => "jp_substitute_holiday(year, month, day)", :function_arguments => [:year, :month, :day], :name => "振替休日", :regions => [:jp]},
        {:mday => 4, :function => "jp_substitute_holiday(year, month, day)", :function_arguments => [:year, :month, :day], :name => "振替休日", :regions => [:jp]},
        {:mday => 5, :function => "jp_substitute_holiday(year, month, day)", :function_arguments => [:year, :month, :day], :name => "振替休日", :regions => [:jp]}],
  7 => [{:mday => 20, :year_ranges => { :between => 1996..2002 },:name => "海の日", :regions => [:jp]},
        {:wday => 1, :week => 3, :year_ranges => { :between => 2003..2019 },:name => "海の日", :regions => [:jp]},
        {:mday => 23, :year_ranges => { :limited => [2020] },:name => "海の日", :regions => [:jp]},
        {:mday => 22, :year_ranges => { :limited => [2021] },:name => "海の日", :regions => [:jp]},
        {:wday => 1, :week => 3, :year_ranges => { :from => 2022 },:name => "海の日", :regions => [:jp]},
        {:function => "jp_marine_day_substitute(year)", :function_arguments => [:year], :year_ranges => { :between => 1996..2002 },:name => "振替休日", :regions => [:jp]},
        {:mday => 23, :year_ranges => { :limited => [2021] },:name => "スポーツの日", :regions => [:jp]},
        {:mday => 24, :year_ranges => { :limited => [2020] },:name => "スポーツの日", :regions => [:jp]}],
  8 => [{:function => "jp_mountain_holiday(year)", :function_arguments => [:year], :year_ranges => { :between => 2016..2019 },:name => "山の日", :regions => [:jp]},
        {:mday => 10, :year_ranges => { :limited => [2020] },:name => "山の日", :regions => [:jp]},
        {:mday => 8, :year_ranges => { :limited => [2021] },:name => "山の日", :regions => [:jp]},
        {:function => "jp_mountain_holiday(year)", :function_arguments => [:year], :year_ranges => { :from => 2022 },:name => "山の日", :regions => [:jp]},
        {:function => "jp_mountain_holiday_substitute(year)", :function_arguments => [:year], :year_ranges => { :between => 2016..2020 },:name => "振替休日", :regions => [:jp]},
        {:mday => 9, :year_ranges => { :limited => [2021] },:name => "振替休日", :regions => [:jp]},
        {:function => "jp_mountain_holiday_substitute(year)", :function_arguments => [:year], :year_ranges => { :from => 2022 },:name => "振替休日", :regions => [:jp]}],
  9 => [{:wday => 1, :week => 3, :name => "敬老の日", :regions => [:jp]},
        {:function => "jp_respect_for_aged_holiday_substitute(year)", :function_arguments => [:year], :name => "振替休日", :regions => [:jp]},
        {:function => "jp_citizens_holiday(year)", :function_arguments => [:year], :year_ranges => { :from => 2003 },:name => "国民の休日", :regions => [:jp]},
        {:function => "jp_national_culture_day(year)", :function_arguments => [:year], :name => "秋分の日", :regions => [:jp]},
        {:function => "jp_national_culture_day_substitute(year)", :function_arguments => [:year], :name => "振替休日", :regions => [:jp]}],
  10 => [{:wday => 1, :week => 2, :year_ranges => { :until => 2019 },:name => "体育の日", :regions => [:jp]},
        {:wday => 1, :week => 2, :year_ranges => { :from => 2022 },:name => "スポーツの日", :regions => [:jp]},
        {:function => "jp_health_sports_day_substitute(year)", :function_arguments => [:year], :name => "振替休日", :regions => [:jp]},
        {:mday => 22, :year_ranges => { :limited => [2019] },:name => "即位礼正殿の儀", :regions => [:jp]}],
  11 => [{:mday => 3, :name => "文化の日", :regions => [:jp]},
        {:mday => 3, :function => "jp_substitute_holiday(year, month, day)", :function_arguments => [:year, :month, :day], :name => "振替休日", :regions => [:jp]},
        {:mday => 23, :name => "勤労感謝の日", :regions => [:jp]},
        {:mday => 23, :function => "jp_substitute_holiday(year, month, day)", :function_arguments => [:year, :month, :day], :name => "振替休日", :regions => [:jp]}],
  12 => [{:mday => 23, :year_ranges => { :until => 2018 },:name => "天皇誕生日", :regions => [:jp]},
        {:mday => 23, :function => "jp_substitute_holiday(year, month, day)", :function_arguments => [:year, :month, :day], :year_ranges => { :until => 2018 },:name => "振替休日", :regions => [:jp]}]
  }
end