モジュール:サンドボックス/FlatLanguage/サンドボックス1
表示
モジュールの解説[作成]
local p = {};
function p.showdate (frame)
local date = frame.args['date']
local year = frame.args['year']
local month = frame.args['month']
local cfg = require ('Module:Citation/CS1/Configuration/sandbox')
local utilities = require ('Module:Citation/CS1/Utilities/sandbox')
local validation = require ('Module:Citation/CS1/Date_validation/sandbox')
local error_list = {}
local COinS_date = {}
local retVal =''
utilities.set_selected_modules (cfg)
validation.set_selected_modules (cfg, utilities)
local date_parameters_list = {['date'] = {val = date}, ['year'] = {val = year}}
if not(date == nil or date == '') and not(year == nil or year == '') then
validation.year_date_check (year, 'year', date, 'date', error_list)
if not(#error_list == 0) then
date_parameters_list['date'].val = date .. ' ' .. year
error_list = {}
end
validation.year_date_check (date_parameters_list['year'].val, 'year', date_parameters_list['date'].val, 'date', error_list)
end
if date == nil or date == '' then
if month == nil or month == '' then
date_parameters_list['date'].val = year
else
if mw.ustring.match(frame:callParserFunction ('#time', 'Ym', month .. ' ' .. year), 'Error') then
date_parameters_list['date'].val = year .. '年' .. month .. '月'
else
date_parameters_list['date'].val = month .. ' ' .. year
end
end
end
validation.dates (date_parameters_list, COinS_date, error_list)
validation.reformat_dates (date_parameters_list, 'ja')
retVal = retVal .. date_parameters_list['date'].val
if not(#error_list == 0) then
retVal = retVal .. frame:expandTemplate{title = 'Citation/showdateError/sandbox', args = {year = year, date = date, month = month}}
elseif year and mw.ustring.match (year, '^([1-9][0-9][0-9][0-9]?)年$') then
retVal = retVal .. frame:expandTemplate{title = 'Citation/showdateError/sandbox', args = {year = year, date = date, month = month}}
end
--[[if date and mw.ustring.match (date, '%[%[.*%]%]') or year and mw.ustring.match (year, '%[%[.*%]%]') then
retVal = retVal .. frame:expandTemplate{title = 'Citation/showdateError/sandbox', args = {year = year, date = date, month = month}}
end]]
return retVal
end
return p