#define INVERTED 1
#define NORMAL 0
var/Timer/MyDate = new(23,59,30,29,11,2013,0)
Timer
var
Mode
Seconds = 0
Minutes = 0
Hours = 0
// New implementation, Months and Years
Day = 1
Month = 1
Year = 1
New(h=0, m=0, s=0, day=1, month=1, year=1, mode = NORMAL)
.=..()
Hours = h
Minutes = m
Seconds = s
Day = day
Month = month
Year = year
Mode = mode
doTime()
proc/doTime()
if(Mode == INVERTED) spawn while(1)
if(!Seconds && !Minutes && !Hours)
del src // Why delete the timer? This inverted timer was designed as a cooldown handler.
// so it can be accessed in many ways; if(src.cooldown)return, for example.
if(--Seconds == 0)
if(--Minutes > -1)
Seconds = 60
if(!Minutes && --Hours > -1)
Minutes = 60
sleep(10)
else if(Mode == NORMAL) spawn while(1)
if(++Seconds >= 60)
Seconds = 0
if(++Minutes >= 60)
Minutes = 0
if(++Hours >= 24)
Hours = 0
var needDays = Month % 2
if(++Day >= (needDays ? 31 : 30))
Day = 1
if(++Month >= 13)
Month = 1
Year++
world << "[Hours<10? "0[Hours]":"[Hours]"]:[Minutes<10? "0[Minutes]":"[Minutes]"]:[Seconds<10? "0[Seconds]":"[Seconds]"] - [Day<10? "0[Day]":"[Day]"], [Month<10? "0[Month]":"[Month]"] [Year]"
sleep(10)
Maybe this is not the best way of handling this, I would also want to know your opinions.