Module:Sandbox/DixonD/Datetime/Julian
Appearance
local z = {}
function z.julianDay(year, month, day, hour, minute, second)
-- set defaults
if month == nil then month = 1; end;
if day == nil then day = 1; end;
if hour == nil then hour = 12; end;
if minute == nil then minute = 0; end;
if second == nil then second = 0; end;
-- http://www.tondering.dk/claus/cal/julperiod.php#formula
local y = year + 4799;
local m = y * 12 + month + 9;
local d = day - 1;
y = math.floor(m / 12);
m = m - y * 12;
return
math.floor(y * 1461 / 4)
+ math.floor((m + 4) * 153 / 5) - 122
+ d
+ (hour - 12) / 24
+ minute / 1440
+ second / 86400
- 32083;
end
return z