Module:Sandbox/DixonD/Datetime: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 4:
this.calendars = {};
 
function this:.registerCalendar(moduleName, ...)
for index in ... do
this.calendars[index] = moduleName; -- loaded lazily
Line 10:
end;
 
this:.registerCalendar("Module:Sandbox/DixonD/Datetime/Gregorian", "Gregorian", "g"); --first position is the default
this:.registerCalendar("Module:Sandbox/DixonD/Datetime/Julian", "Julian", "j");
-- more calendars may be added later in new modules pluggable here into this factory...
 
function this:.selectCalendar(index)
if index == nil then
index = 0; -- use the default calendar (Gregorian as set above)
Line 42:
 
-- main functions
function this:.julianDay(year, month, day, hour, minute, second, calendar)
calendar = this:.selectCalendar(calendar);
if calendar == nil then
return tostring(Error.error{"Calendar ''" .. calendar .. "'' is either missing or unknown!"});
Line 51:
end;
 
function this:.dateOfJulianDay(julianDay, calendar)
calendar = this:.selectCalendar(calendar);
if calendar == nil then
return tostring(Error.error{"Calendar ''" .. calendar .. "'' is either missing or unknown!"});
Line 60:
end;
 
function this:.yearOfJulianDay(julianDay, calendar)
calendar = this:.selectCalendar(calendar);
if calendar == nil then
return tostring(Error.error{"Calendar ''" .. calendar .. "'' is either missing or unknown!"});
Line 69:
end;
function this:.monthOfJulianDay(julianDay, calendar)
calendar = this:.selectCalendar(calendar);
if calendar == nil then
return tostring(Error.error{"Calendar ''" .. calendar .. "'' is either missing or unknown!"});
Line 78:
end;
function this:.dayOfJulianDay(julianDay, calendar)
calendar = this:.selectCalendar(calendar);
if calendar == nil then
return tostring(Error.error{"Calendar ''" .. calendar .. "'' is either missing or unknown!"});
Line 87:
end;
function this:.weekdayOfJulianDay(julianDay, calendar)
calendar = this:.selectCalendar(calendar);
if calendar == nil then
return tostring(Error.error{"Calendar ''" .. calendar .. "'' is either missing or unknown!"});
Line 96:
end;
function this:.hourOfJulianDay(julianDay, calendar)
calendar = this:.selectCalendar(calendar);
if calendar == nil then
return tostring(Error.error{"Calendar ''" .. calendar .. "'' is either missing or unknown!"});
Line 105:
end;
function this:.minuteOfJulianDay(julianDay, calendar)
calendar = this:.selectCalendar(calendar);
if calendar == nil then
return tostring(Error.error{"Calendar ''" .. calendar .. "'' is either missing or unknown!"});
Line 114:
end;
function this:.secondOfJulianDay(julianDay, calendar)
calendar = this:.selectCalendar(calendar);
if calendar == nil then
return tostring(Error.error{"Calendar ''" .. calendar .. "'' is either missing or unknown!"});