Module:Bengali Unix Timestamp
Appearance
![]() | This module is rated as alpha. It is ready for third-party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome. |
This is a module which gives the Unix Timestamp for Bengali Calender and It's calculated from the 1 Boisakh 1432 (14 April 2025). It is using UTC+6
The Current Timestamp is: 2505090
Usage
{{#invoke:Bengali Unix Timestamp|main}}
Returns: 2505090
We can also use the Gegorian Date to get the Bengali Timestamp of that day.
Like:
{{#invoke:Bengali Unix Timestamp|main|14 April 2025}}
Gives: Lua error at line 35: attempt to perform arithmetic on global 'timestamp' (a nil value). [As it counts from 14 April 2025]
local p = {}
local MONTH = {
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
if date then
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 = MONTH[month]
end
end
if not (year and month and day) then
return "Invalid date format. Use DD-YYYY-MM or DD Month YYYY."
end
local timestamp = os.time{
year = tonumber(year),
month = tonumber(month),
day = tonumber(day),
hour = 0
}
else
timestamp = os.time()
end
timestamp = timestamp - os.difftime(os.time(), os.time(os.date("!*t"))) + 21600
return timestamp
end
function p.main(frame)
local UNIX = tonumber(en_timestamp(frame.args[1]))
local BN_UNIX = UNIX - 1744610400
return BN_UNIX
end
return p