মডিউল:ConvertTime

উইকিবই থেকে

উদ্দেশ্য[সম্পাদনা]

এই মডিউলটি প্রধানত বানানো হয়েছে যেহেতু {{#time}} পার্সর ফাংশন বাংলা মাসের গণনা করতে সক্ষম নয়। যা একটি বাগ অবিলম্বে (বাগ 19412) করা হয়েছে। এই বাগটি ফিক্স হয়েগেল এই মডিউলটি আর কোনো প্রয়োজন নেই বা থাকবে না।

উদাহরণ:

  • {{#time:F Y|{{CURRENTMONTHNAME}} {{CURRENTYEAR}}}} দিলে আমরা পাই: ত্রুটি: অবৈধ সময়

প্রয়োগের উদাহরণ[সম্পাদনা]

{{#invoke:ConvertTime|main|<!-- your text here -->}}
For example, {{#invoke:ConvertTime|main|১৬:২৫, ৩ এপ্রিল ২০১৩ (ইউটিসি)}} produces "16:25, 3 April 2013 (ইউটিসি)"


উদাহরণ:

  • {{#time:F Y|{{#invoke:ConvertTime|main|{{CURRENTMONTHNAME}} {{CURRENTYEAR}}}}}} দিলে আমরা পাই:এপ্রিল ২০২৪

-- 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 -->}}.