Posted 18 April 2013 - 04:20 AM
I made a simple API that converts os.day() into a days of month, months, and years. (Starts on Day 1, Month 1, Year 0)
pastebin get u5V5bEc4 dateapi
This api only has one functions
day,month,year = dateapi.getDate()
Example Program as seen in screen shot above.
pastebin get u5V5bEc4 dateapi
Spoiler
function getDate()
local worldDays = os.day()
local month = 1
local day = worldDays
local year = 1
local leap = 28
-- get Year
i = 1
daysInYear = 365
while day > daysInYear do
if 1 < 4 then
daysInYear = 365
i = i + 1
leap = 28
else
daysInYear = 366
i = 1
leap = 29
end
year = year + 1
day = day - daysInYear
end
-- get Month
-- January
if day > 31 then
day = day - 31
month = month + 1
end
-- February
if day > leap then
day = day - leap
month = month + 1
end
-- March
if day > 31 then
day = day - 31
month = month + 1
end
-- April
if day > 30 then
day = day - 30
month = month + 1
end
-- May
if day > 31 then
day = day - 31
month = month + 1
end
-- June
if day > 30 then
day = day - 30
month = month + 1
end
-- July
if day > 31 then
day = day - 31
month = month + 1
end
-- August
if day > 31 then
day = day - 31
month = month + 1
end
-- September
if day > 30 then
day = day - 30
month = month + 1
end
-- October
if day > 31 then
day = day - 31
month = month + 1
end
-- November
if day > 30 then
day = day - 30
month = month + 1
end
-- December
if day > 31 then
day = day - 31
month = 1
year = year + 1
end
return day,month,year
end
This api only has one functions
day,month,year = dateapi.getDate()
Example Program as seen in screen shot above.
Spoiler
os.loadAPI("dateapi")
day,month,year = dateapi.getDate()
print(day .. "/" .. month .. "/" .. year)
Edited on 27 November 2013 - 11:32 AM