Module:LatestUpdate: Difference between revisions

No edit summary
No edit summary
Line 35: Line 35:
local function getMonthNumber(monthName)
local function getMonthNumber(monthName)
     return month_map[monthName]
     return month_map[monthName]
end
local function getCurrentTime()
    local frame = mw.getCurrentFrame()
    local now_str = frame:callParserFunction("CURRENTTIMESTAMP", "")
    return os.time({
        year = tonumber(string.sub(now_str, 1, 4)),
        month = tonumber(string.sub(now_str, 5, 6)),
        day = tonumber(string.sub(now_str, 7, 8)),
        hour = 0
    })
end
end


Line 64: Line 52:
     })
     })


     local now = getCurrentTime()
     local now = os.time()


     local diff_seconds = os.difftime(now, update_time)
     local diff_seconds = os.difftime(now, update_time)
Line 79: Line 67:
function p.days_since_text()
function p.days_since_text()
     local days = p.days_since()
     local days = p.days_since()
     return days .. (days == 1 and " day ago" or " days ago")
     return days .. (days == 1 and " day ago" or " days ago")
end
end


return p
return p