ماڊيول:EnDigitConverter
ڏيک
Documentation for this module may be created at ماڊيول:EnDigitConverter/doc
local p = {}
-- Sindhi month names mapped to month numbers
local sindhi_months = {
['01'] = 'جنوري', -- January
['02'] = 'فيبروري', -- February
['03'] = 'مارچ', -- March
['04'] = 'اپريل', -- April
['05'] = 'مئي', -- May
['06'] = 'جون', -- June
['07'] = 'جولاءِ', -- July
['08'] = 'آگسٽ', -- August
['09'] = 'سيپٽمبر', -- September
['10'] = 'آڪٽوبر', -- October
['11'] = 'نومبر', -- November
['12'] = 'ڊسمبر', -- December
}
-- English month names mapped to Sindhi month names for fallback or alternative parsing
local english_months = {
['january'] = 'جنوري',
['february'] = 'فيبروري',
['march'] = 'مارچ',
['april'] = 'اپريل',
['may'] = 'مئي',
['june'] = 'جون',
['july'] = 'جولاءِ',
['august'] = 'آگسٽ',
['september'] = 'سيپٽمبر',
['october'] = 'آڪٽوبر',
['november'] = 'نومبر',
['december'] = 'ڊسمبر',
}
function p._main(date)
if not date or date == '' then
return date
end
-- Trim whitespace
date = mw.text.trim(date)
-- Check for YYYY-MM-DD format
local year, month, day = date:match('^(%d%d%d%d)%-(%d%d)%-(%d%d)$')
if year and month and day then
local sindhi_month = sindhi_months[month]
if sindhi_month then
-- Return in DMY format without dot: DD Month YYYY
return day .. ' ' .. sindhi_month .. ' ' .. year
else
-- Invalid month, return original date
return date
end
end
-- Check for English month name format (e.g., "March 15, 2024")
local eng_month, eng_day, eng_year = date:match('^([A-Za-z]+)%s+(%d%d?),?%s+(%d%d%d%d)$')
if eng_month and eng_day and eng_year then
local sindhi_month = english_months[eng_month:lower()]
if sindhi_month then
-- Return in DMY format without dot: DD Month YYYY
return eng_day .. ' ' .. sindhi_month .. ' ' .. eng_year
end
end
-- If date format is unrecognized, return original date
return date
end
return p