मॉड्यूल:ConvertTime
दिखावट
Purpose
[सम्पादित करें]{{#time}} parsor function not work any more at calculation of date and month.(Bug 19412) this is the bug already documented.
Example of issue:
{{#time:F Y|{{CURRENTMONTHNAME}} {{CURRENTYEAR}}}}giver a error message: त्रुटि: अमान्य समय।
{{#time:Y|{{CURRENTYEAR}}-60}}giver a error message:: त्रुटि: अमान्य समय।
Application Example
[सम्पादित करें]{{#invoke:ConvertTime|main|<!-- your text here -->}}
- For example,
{{#invoke:ConvertTime|main|१२:३०, २९ अप्रैल २०१५}}produces "12:30, 29 April 2015"
Example:
{{#time:F Y|{{#invoke:ConvertTime|main|{{CURRENTMONTHNAME}} {{CURRENTYEAR}}}}}}result:जून २०२६
{{#time: Y|{{#invoke:ConvertTime|main|{{CURRENTYEAR}}}}-60}}result:त्रुटि: अमान्य समय।
-- First, define a table of text to search for, and what to convert it to.
local conversionTable = {
['जनवरी'] = 'January',
['फ़रवरी'] = 'February',
['मार्च'] = 'March',
['अप्रैल'] = 'April',
['मई'] = 'May',
['जून'] = 'June',
['जुलाई'] = 'July',
['अगस्त'] = 'August',
['सितम्बर'] = 'September',
['अक्टूबर'] = 'October',
['नवम्बर'] = 'November',
['दिसम्बर'] = 'December',
['०'] = '0',
['१'] = '1',
['२'] = '2',
['३'] = '3',
['४'] = '4',
['५'] = '5',
['६'] = '6',
['७'] = '7',
['८'] = '8',
['९'] = '9',
}
-- Then we define a table to hold our function
local p = {}
-- Then we define a function that converts strings using conversionTable.
function p.main(frame)
local s = frame.args[1] -- This gets the first positional argument.
for bn, en in pairs(conversionTable) do -- This converts every string found in the table.
s = mw.ustring.gsub(s, bn, en)
end
return s -- Get the result of the function.
end
return p -- Pass our table containing our function back to Lua.
-- Now we can call our function using {{#invoke:ConvertTime|main|<!-- your text here -->}}.