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 1:
local p = {}
local monthMap = {
January = 1, February = 2, March = 3, April = 4, May = 5, June = 6,
July = 7, August = 8, September = 9, October = 10, November = 11, December = 12
}
 
local function en_timestamp(date)
local input = date
local year, month, day
 
day, month, month = input:match("(%d+)%-(%d+)%-(%d+)")
if not (year and month and day) then
day, month, year = input:match("(%d+)%s+(%a+)%s+(%d+)")
if month then
month = monthMap[month]
end
end
 
if not (year and month and day) then
return "Invalid date format. Use YYYY-MM-DD or DD Month YYYY."
end
 
local timestamp = os.time{
year = tonumber(year),
month = tonumber(month),
day = tonumber(day),
hour = 0
}
 
timestamp = timestamp - os.difftime(os.time(), os.time(os.date("!*t"))) + 21600
 
return timestamp
end
 
 
 
function p.main(frame)
local UNIX = en_timestamp(frame.args[1] or os.time()"23 +April 216002025")
local BN_UNIX = UNIX - 1744643600
return BN_UNIX