Module:ScheduleList:修订间差异

跳转到导航 跳转到搜索
创建页面,内容为“local p = {} -- 工具函数:判断是否为闰年 local function is_leap_year(year) return (year % 4 == 0 and year % 100 ~= 0) or (year % 400 == 0) end -- 工具函数:计算每月天数 local function days_in_month(month, year, leap_year) local days = {31, leap_year and 29 or 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} return days[month] end -- 工具函数:计算下一个日期 local function get_next_date(date, leap_year) local mont…”
 
无编辑摘要
第46行: 第46行:
     local week = tonumber(args.week)
     local week = tonumber(args.week)
     local leap_year = args.leap_year == "yes"
     local leap_year = args.leap_year == "yes"
    local time_defaults = {}
      
      
     -- 如果没有输入初始日期,则报错
     -- 如果没有输入初始日期,则报错
第62行: 第61行:
         local time = args["time" .. i] or "2:00" -- 未提供时间时默认 "2:00"
         local time = args["time" .. i] or "2:00" -- 未提供时间时默认 "2:00"
         local week_day = get_next_weekday(current_weekday - 1) -- 计算周几
         local week_day = get_next_weekday(current_weekday - 1) -- 计算周几
       
        -- 调用 ruby 模板
        local ruby_output = frame:expandTemplate{
            title = "ruby",
            args = {current_date, time}
        }
          
          
         -- 格式化当前行
         -- 格式化当前行
         table.insert(result, string.format("{{ruby|%s|%s}}<small>%s</small> %s", current_date, time, week_day, title))
         table.insert(result, string.format("%s<small>%s</small> %s", ruby_output, week_day, title))
          
          
         -- 更新日期和周几
         -- 更新日期和周几