Module:Bengali Unix Timestamp: Difference between revisions

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
Line 6:
 
local function en_timestamp(date)
if ifnot date then
local input = date
return os.time() + 21600 -- fallback to current time (UTC+6)
local timestamp
end
local year, month, day
if date then
day, month, year = input:match("(%d+)%-(%d+)%-(%d+)")
 
iflocal not (year andday, month, and day) thenyear
 
day, month, year = input:match("(%d+)%s+(%a+)%s+(%d+)")
-- Format: DD-MM-YYYY
day, month, year = inputdate:match("(%d+)%-(%d+)%-(%d+)")
-- Format: DD Month YYYY
if not (day and month and year) then
day, month, year = inputdate:match("(%d+)%s+(%a+)%s+(%d+)")
if month then
month = MONTH[month]
Line 20 ⟶ 23:
end
 
if not (yearday and month and dayyear) then
return "Invalid date format. Use DD-YYYY-MM-YYYY or DD Month YYYY."
end
 
local timestamp = os.time{
year = tonumber(year),
month = tonumber(month),
Line 30 ⟶ 33:
hour = 0
}
else
timestamp = os.time()
end
timestamp = timestamp - os.difftime(os.time(), os.time(os.date("!*t"))) + 21600
return timestamp
end
 
 
-- Add 6 hours to convert to UTC+6 (Bangladesh Time)
localreturn timestamp + 21600
end
 
function p.main(frame)
Line 47 ⟶ 43:
return BN_UNIX
end
 
return p