Mô đun:Mẫu Lập lịch theo tuần
Tài liệu mô đun[tạo]
local p = {};
local vi = mw.language.new( "vi" )
p.init = function( frame )
local year = mw.text.trim( frame.args[1] )
local out = {}
local weeks_of_year = {}
local days_of_week = {}
local current_weeknum
for daynum = 1, max_daynum( year ), 1 do
local weeknum = trim_leading( vi:formatDate( "W", year .. "-01-01 + " .. daynum - 1 .. " days" ) )
if weeknum ~= current_weeknum then
current_weeknum = weeknum
days_of_week = { week = current_weeknum }
table.insert( weeks_of_year, days_of_week )
end
table.insert( days_of_week, daynum )
end
local result = ""
for _, days in pairs( weeks_of_year ) do
result = result .. "| <!--@ Tuần " .. days.week .. " @--> " .. table.concat( days, '|' ) .. " = \n"
end
return mw.text.trim( result )
end
function trim_leading( weeknum )
local result
if tonumber( weeknum ) < 10 then
result = mw.text.trim( weeknum , "0" )
else
result = weeknum
end
return result
end
function max_daynum( year )
local leap = vi:formatDate( "L", year )
if leap == "1" then
return 366
else
return 365
end
end
return p
Wiki - Keonhacai copa chuyên cung cấp kiến thức thể thao, keonhacai tỷ lệ kèo, bóng đá, khoa học, kiến thức hằng ngày được chúng tôi cập nhật mỗi ngày mà bạn có thể tìm kiếm tại đây có nguồn bài viết: https://vi.wikipedia.org/wiki/M%C3%B4_%C4%91un:M%E1%BA%ABu_L%E1%BA%ADp_l%E1%BB%8Bch_theo_tu%E1%BA%A7n