ID:195075
 
//Title: NiceTime()
//Credit to: Public domain
//Contributed by: YMIHere


/*
This snippets turns a boring old number into a text string
reflecting time in the form of x weeks x days x hours x minutes x ticks.
*/



proc
NiceTime(time)
var/list/measures=list("week"=6048000,"day"=864000,\
"hour"=36000,"minute"=600,"second"=10,"tick"=1)
var/string
for(var/measure in measures)
var/how_many = round(time / measures[measure])
if(how_many >= 1)
string += "[how_many] [measure]"
if(how_many >= 2)
string += "s"
string += " "
time -= how_many*measures[measure]
return copytext(string, 1, length(string))


///*
//Testing Code/Sample Implementation:

mob/var/time_joined
mob/verb/how_long_have_I_been_here()
src << NiceTime(world.realtime-time_joined)
mob/verb/test(n as num)
src << NiceTime(n)

mob/Login()
..()
time_joined=world.realtime

//*/