モジュール:ReleaseCalendar
提供:エンタメデータベースWiki
このモジュールについての説明文ページを モジュール:ReleaseCalendar/doc に作成できます
local p = {}
-- 月のコンテンツカレンダーへのリンクを生成
local function getMonthlyCalendarLink()
local currentDate = os.date('!*t') -- UTC時間を取得
-- 年と月を2桁で取得(例:2025年02月)
local year = currentDate.year
local month = string.format('%02d', currentDate.month)
local url = string.format('https://www.h1g.jp/contents/%d年%02d月', year, month)
return string.format('[%s もっと見る]', url)
end
-- 週の開始日(月曜)と終了日(日曜)を取得する関数
local function getWeekRange()
local currentDate = os.date('!*t') -- UTC時間を取得
local currentWeekday = currentDate.wday
local daysToMonday = currentWeekday == 1 and -6 or -(currentWeekday - 2)
-- 週初め(月曜日)の日時を設定
local mondayDate = os.time({
year = currentDate.year,
month = currentDate.month,
day = currentDate.day + daysToMonday,
hour = 9, -- JST 09:00 = UTC 00:00
min = 0,
sec = 0
})
-- 週末(日曜日)の日時を設定(月曜日+6日)
local sundayDate = os.time({
year = currentDate.year,
month = currentDate.month,
day = currentDate.day + daysToMonday + 6,
hour = 23,
min = 59,
sec = 59
})
return os.date('%Y年%m月%d日', mondayDate),
os.date('%Y年%m月%d日', sundayDate)
end
-- ゲームのリリース情報を取得
function p.getGameReleases(frame)
local startDate, endDate = getWeekRange()
local query = '{{#ask: [[Category:ゲーム]] [[リリース::>' .. startDate .. ']] [[リリース::<' .. endDate .. ']]' ..
' |?リリース' ..
' |?display-name' ..
' |?画像' ..
' |?大カテゴリ#=-5' ..
' |?ラベル#=-4' ..
' |sort=リリース' ..
' |order=asc' ..
' |limit=10' ..
' |format=template' ..
' |template=ReleaseCalendarTabTemplate' ..
'}}'
return frame:preprocess(query)
end
-- エンターテインメントのリリース情報を取得
function p.getEntertainmentReleases(frame)
local startDate, endDate = getWeekRange()
local query = '{{#ask: [[Category:アニメ||実写映画||アニメ映画||スポーツ||舞台||メディア||リアルイベント||ホビー||書籍||トレカ||音楽]]' ..
' [[リリース::>' .. startDate .. ']] [[リリース::<' .. endDate .. ']]' ..
' |?リリース' ..
' |?display-name' ..
' |?画像' ..
' |?大カテゴリ#=-5' ..
' |?ラベル#=-4' ..
' |sort=リリース' ..
' |order=asc' ..
' |limit=10' ..
' |format=template' ..
' |template=ReleaseCalendarTabTemplate' ..
'}}'
return frame:preprocess(query)
end
-- 月のコンテンツカレンダーへのリンクを取得
function p.getMonthlyCalendarLink(frame)
return getMonthlyCalendarLink()
end
return p