ID:549814
 
(See the best response by Albro1.)
Code:
proc
ConvertTime(format="d/m/y g:i.s A",offset=0,timestamp=world.realtime)
if(isnum(offset)) offset = round(offset) * 36000
else
var/p = findtext(offset,":")
if(p) offset = (round(text2num(copytext(offset,1,p))) * 36000) + (round(text2num(copytext(offset,p+1))) * 600)
else offset = round(text2num(offset)) * 36000
timestamp += offset
for(var/i=1;i<=length(format);i++)
switch(text2ascii(format,i))
if(111)
if(i > 1 && ((text2ascii(format,i-1) == 68 || text2ascii(format,i-1) == 100))) . += ((time2text(timestamp,"DD") == "1" || time2text(timestamp,"DD") == "21" || time2text(timestamp,"DD") == "31") ? "st" : ((time2text(timestamp,"DD") == "2" || time2text(timestamp,"DD") == "22") ? "nd" : ((time2text(timestamp,"DD") == "3" || time2text(timestamp,"DD") == "23") ? "rd" : "th")))
else . += copytext(format,i,i+1)
if(65,97) . += (text2num(time2text(timestamp,"hh")) >= 0 && text2num(time2text(timestamp,"hh")) < 12 ? (text2ascii(format,i) == 65 ? "AM" : "am") : (text2ascii(format,i) == 65 ? "PM" : "pm"))
if(115) . += time2text(world.timeofday,"ss")
if(105) . += time2text(timestamp,"mm")
if(103) . += num2text(round((text2num(time2text(timestamp,"hh"))+11)%12+1))
if(71) . += time2text(timestamp,"hh")
if(104) . += (round((text2num(time2text(timestamp,"hh"))+11)%12+1) < 10 ? ("0"+num2text(round((text2num(time2text(timestamp,"hh"))+11)%12+1))) : num2text(round((text2num(time2text(timestamp,"hh"))+11)%12+1)))
if(72) . += "[text2num(time2text(timestamp,"hh")) < 10 ? "0[time2text(timestamp,"hh")]" : time2text(timestamp,"hh")]"
if(100) . += (text2num(time2text(timestamp,"DD")) < 10 ? copytext(time2text(timestamp,"DD"),2) : time2text(timestamp,"DD"))
if(68) . += time2text(timestamp,"DD")
if(116) . += time2text(timestamp,"DDD")
if(109) . += time2text(timestamp,"MM")
if(77) . += (text2num(time2text(timestamp,"MM")) < 10 ? "0[time2text(timestamp,"MM")]" : "[time2text(timestamp,"MM")]")
if(117) . += time2text(timestamp,"MMM")
if(89) . += time2text(timestamp,"YYYY")
if(121) . += time2text(timestamp,"YY")
else . += copytext(format,i,i+1)


Description:
Is it possible from what i have here to code a proc that every saturday and every specific hour that proc will activate? If it is can someone can show me how pelase. I want to create happy hours and bonus exp on saturday ^^


Best response
You could simplify it a lot.

mob
proc
checkTime()
var/day = time2text(world.realtime, "Day") // This will grab the current day, fully spelled out.
var/time = time2text(world.realtime, "hh:mm") // This will grab the time, in hh:mm format
if(day == "Saturday") // If it's Saturday
if(time == "14:00") // And it's 2 PM
do_event() // start the event.
else // If it isn't 2 PM...
if(time == "15:00") // And it's actually 3 PM,
stop_event() // Then our event that started at 2 needs to end.
Ty so much :)
No problem. Vote up my response ;P