Content deleted Content added
No edit summary Tags: Mobile edit Mobile web edit Advanced mobile edit |
No edit summary Tags: Mobile edit Mobile web edit Advanced mobile edit |
||
(9 intermediate revisions by the same user not shown) | |||
Line 1:
local p = {}
local MONTH = {
January = 1, February = 2, March = 3, April = 4, May = 5, June = 6,
Line 6 ⟶ 7:
local function en_timestamp(date)
if date then▼
-- Format: DD-MM-YYYY
end▼
▲if date then
-- Format: DD Month YYYY
if not (year and month and day) then▼
if not (day
day, month, year = date:match("(%d+)%s+(%a+)%s+(%d+)")
if month then▼
if month
month = month:sub(1,1):upper() .. month:sub(2):lower()
end
year = tonumber(year),▼
day = tonumber(day),
hour = 0▼
}
-- Add 6 hours to convert to UTC+6 (Bangladesh Time)
else
return os.time() + 21600 -- fallback to current time (UTC+6)
end
end
▲ return "Invalid date format. Use DD-YYYY-MM or DD Month YYYY."
▲ end
function p._main(date)
▲ local timestamp = os.time{
local UNIX, err = en_timestamp(date)
▲ year = tonumber(year),
if not UNIX then
▲ month = tonumber(month),
▲ day = tonumber(day),
else
▲ hour = 0
return UNIX - 1744610400
▲ if not timestamp
end
▲ return timestamp
end
function p.main(frame)
local
▲ return UNIX
return result
else
return err or "Invalid or missing date."
end
end
return p
|