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 |
||
(5 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
day, month, year = input:match("(%d+)%-(%d+)%-(%d+)")▼
-- Format: DD-MM-YYYY
if not (year and month and day) then▼
day, month, year =
if month then▼
-- Format: DD Month YYYY
month = MONTH[month]▼
▲ if month then
month = month:sub(1,1):upper() .. month:sub(2):lower()
▲ month = MONTH[month]
end
▲ end
return nil, "Invalid date format. Use DD
year = tonumber(year),▼
month = tonumber(month),▼
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
function p._main(date)
▲ timestamp = os.time{
local UNIX, err = en_timestamp(date)
▲ year = tonumber(year),
if not UNIX then
▲ month = tonumber(month),
▲ day = tonumber(day),
▲ hour = 0
else
return UNIX - 1744610400
end
▲ end
▲ return timestamp
end
function p.main(frame)
local
local
if result then
▲ return BN_UNIX
return result
else
return err or "Invalid or missing date."
end
end
return p
|