ഘടകം:Date
ഈ ഘടകത്തിന്റെ വിവരണം ഘടകം:Date/വിവരണം എന്ന താളിൽ നിർമ്മിക്കാവുന്നതാണ്
--[[
This module is intended for processing of date strings
]]
local date = {}
-----------------------------------------------
-- Translation data to Malayalam language
-----------------------------------------------
local date_data = require("Module:Date/data");
--[[
ISOyear
This function returns year part of date string.
Usage:
{{#invoke:Date|ISOyear|s=target_string}}
Parameters
s: The date string
If invoked using named parameters, Mediawiki will automatically remove any leading or
trailing whitespace from the target string.
]]
function date.ISOyear( frame )
local s = frame.args.s
-- if empty string then return it
if mw.ustring.len(s) == 0 then
return s
end
-- if number then return it
if tonumber( s ) then
return mw.ustring.format('%04i', s)
end
-- otherwise use regular expression match
s = mw.ustring.match( s, '(-?%d%d?%d?%d?)-' )
if s then
return mw.ustring.format('%04i', s)
else
return ''
end
end
--[[
Get the name of an era, based on Wikisource's definition.
This implements the logic of Template:What_era_is
]]
function date.era( year )
-- Unknown value.
if year == nil or tonumber( year ) == nil or string.lower( year ) == 'unknown' or year == '?' then
return 'Unknown era'
end
-- Handle numeric years.
year = tonumber( year )
if year == nil or year < 601 then
return date_data.data_config['Ancient']
elseif year < 1421 then
return date_data.data_config['Medieval']
elseif year < 1631 then
return 'Renaissance'
elseif year < 1900 then
return date_data.data_config['Early modern']
elseif year < ( tonumber( os.date( '%Y' ) ) + 1 ) then
return date_data.data_config['Modern']
else
return 'Future'
end
end
return date