Module:Nepali date: Difference between revisions
From Test Wiki
Content deleted Content added
AD → BS converter (1975–2099) |
Remove ISO |
||
| (One intermediate revision by the same user not shown) | |||
| Line 7: | Line 7: | ||
-- Nepali month names (Baisakh..Chaitra) |
-- Nepali month names (Baisakh..Chaitra) |
||
local np_months = { |
local np_months = { |
||
" |
"वैशाख","जेठ","असार","साउन","भदौ","असोज", |
||
" |
"कात्तिक","मङ्सिर","पुष","माघ","फागुन","चैत" |
||
} |
} |
||
| Line 281: | Line 281: | ||
end |
end |
||
-- Main public function: AD -> BS ( |
-- Main public function: AD -> BS (Nepali style) |
||
function p.ad2bs(frame) |
function p.ad2bs(frame) |
||
local args = frame.args or {} |
local args = frame.args or {} |
||
| Line 287: | Line 287: | ||
local m = tonumber(args.month) or tonumber(args[2]) |
local m = tonumber(args.month) or tonumber(args[2]) |
||
local d = tonumber(args.day) or tonumber(args[3]) |
local d = tonumber(args.day) or tonumber(args[3]) |
||
local fmt = args.format or "iso" |
|||
if not valid_ad_date(y, m, d) then |
if not valid_ad_date(y, m, d) then |
||
| Line 302: | Line 301: | ||
end |
end |
||
| ⚫ | |||
if fmt == "nepali" then |
|||
local ad_month_name = np_ad_months[m] or tostring(m) |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
to_nepali_digits(bs_y), bs_month_name, to_nepali_digits(bs_d) |
|||
| ⚫ | |||
| ⚫ | |||
) |
|||
else |
|||
return string.format("%04d-%02d-%02d (वि.सं. %04d-%02d-%02d)", |
|||
y, m, d, bs_y, bs_m, bs_d |
|||
) |
|||
| ⚫ | |||
end |
end |
||