モジュール:IsHoliday
表示
![](http://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Test_Template_Info-Icon_-_Version_%282%29.svg/50px-Test_Template_Info-Icon_-_Version_%282%29.svg.png)
p = {}
local function shumbun(y)
-- 春分日を計算 耐用年数:1900年 - 2099年
local d = 99
d = math.floor(20.8431+0.242194*(y-1980))-math.floor((y-1980)/4)
return d
end
local function shubun(y)
-- 秋分日を計算 耐用年数:1900年 - 2099年
local d = 99
d = math.floor(23.2488+0.242194*(y-1980))-math.floor((y-1980)/4)
return d
end
local function ymd2mjd(y, m, d)
return require('Module:MJD').ymd2mjd( { y, m, d } )
end
function p.main(frame)
local args
if type(frame.args) == 'table' then
args = frame.args
else
args = frame
end
local y = tonumber(args[1])
local m = tonumber(args[2])
local d = tonumber(args[3])
local mjd = ymd2mjd(y, m, d)
local n = math.floor((d + 6) / 7) -- 「第n日曜日」などのn
local w = (mjd + 3) % 7 -- 0(日曜日)~6(土曜日)
local t = ''
if ymd2mjd(1948, 7, 20) <= mjd then
if m == 1 then
if d == 1 then
t = '元日'
elseif d == 2 and w == 1 and 1974 <= y then
t = '振替休日'
elseif (d == 15 and y <= 1999) or (n == 2 and w == 1 and 2000 <= y) then
t = '成人の日'
elseif d == 16 and w == 1 and 1974 <= y and y <= 1999 then
t = '振替休日'
end
elseif m == 2 then
if d == 11 and 1967 <= y then
t = '建国記念の日'
elseif d == 12 and w == 1 and 1974 <= y then
t = '振替休日'
elseif d == 23 and 2020 <= y then
t = '天皇誕生日'
elseif d == 24 and y == 1989 then
t = '昭和天皇の大喪の礼'
elseif d == 24 and w == 1 and 2019 <= y then
t = '振替休日'
end
elseif m == 3 then
local shumbun = shumbun(y)
if d == shumbun then
t = '春分の日'
elseif d == (shumbun + 1) and w == 1 and 1973 <= y then
t = '振替休日'
end
elseif m == 4 then
if d == 10 and y == 1959 then
t = '皇太子明仁親王の結婚の儀'
elseif d == 29 and 2007 <= y then
t = '昭和の日'
elseif d == 29 and 1989 <= y then
t = 'みどりの日'
elseif d == 29 then
t = '天皇誕生日'
elseif d == 30 and w == 1 and 1973 <= y then
t = '振替休日'
elseif d == 30 and y == 2019 then
t = '国民の休日'
end
elseif m == 5 then
if d == 1 and y == 2019 then
t = '即位の日'
elseif d == 2 and y == 2019 then
t = '国民の休日'
elseif d == 3 then
t = '憲法記念日'
elseif d == 4 and 2007 <= y then
t = 'みどりの日'
elseif d == 4 and w == 1 and 1973 <= y then
t = '振替休日'
elseif d == 4 and w ~= 0 and 1986 <= y then
t = '国民の休日'
elseif d == 5 then
t = 'こどもの日'
elseif d == 6 and ((w == 1 and 1973 <= y) or ((w == 2 or w == 3) and 2007 <= y)) then
t = '振替休日'
end
elseif m == 6 then
if d == 9 and y == 1993 then
t = '皇太子徳仁親王の結婚の儀'
end
elseif m == 7 then
if (d == 20 and 1996 <= y and y <= 2002)
or (n == 3 and w == 1 and 2003 <= y and y ~= 2020 and y ~= 2021)
or (d == 23 and y == 2020)
or (d == 22 and y == 2021) then
t = '海の日'
elseif d == 21 and w == 1 and 1996 <= y and y <= 2002 then
t = '振替休日'
elseif (d == 24 and y == 2020) or (d == 23 and y == 2021) then
t = 'スポーツの日'
end
elseif m == 8 then
if (d == 11 and 2016 <= y and y ~= 2020 and y ~= 2021)
or (d == 10 and y == 2020)
or (d == 8 and y == 2021) then
t = '山の日'
elseif (d == 12 and w == 1 and 2016 <= y)
or (d == 9 and y == 2021) then
t = '振替休日'
end
elseif m == 9 then
local shubun = shubun(y)
if d == shubun then
t = '秋分の日'
elseif d == (shubun + 1) and w == 1 and 1973 <= y then
t = '振替休日'
elseif (d == 15 and 1966 <= y and y <= 2002) or (n == 3 and w == 1 and 2003 <= y) then
t = '敬老の日'
elseif (d == 16 and w == 1 and 1973 <= y and y <= 2002) then
t = '振替休日'
elseif d == (shubun - 1) and w == 2 and 16 <= d and d <= 22 and 2003 <= y then
t = '国民の休日' -- 出現条件は「秋分の日の前日(shubun - 1)」かつ「敬老の日の翌日(16 <= d <= 22)」
end
elseif m == 10 then
if (d == 10 and 1966 <= y and y <= 1999) or (n == 2 and w == 1 and 2000 <= y and y <= 2019) then
t = '体育の日'
elseif n == 2 and w == 1 and 2022 <= y then
t = 'スポーツの日'
elseif (d == 11 and w == 1 and 1973 <= y and y <= 1999) then
t = '振替休日'
elseif d == 22 and y == 2019 then
t = '即位礼正殿の儀'
end
elseif m == 11 then
if d == 3 then
t = '文化の日'
elseif d == 4 and w == 1 and 1973 <= y then
t = '振替休日'
elseif d == 12 and y == 1990 then
t = '即位礼正殿の儀'
elseif d == 23 then
t = '文化の日'
elseif d == 24 and w == 1 and 1973 <= y then
t = '振替休日'
end
elseif m == 12 then
if d == 23 and 1989 <= y and y <= 2018 then
t = '天皇誕生日'
elseif d == 24 and w == 1 and 1989 <= y and y <= 2018 then
t = '振替休日'
end
end
end
return t
end
return p