ID:156966
 
I'm wondering if there's a function someone would be nice enough to share that would convert a string containing a date/time into BYOND time (1/10th of seconds since 1/1/00)

Similar to http://php.net/strtotime though I'd expect it'd have a more restrictive set of allowed parameters.


Maybe there's a simple way to do this that I'm overlooking?
Maybe you could make something in PHP to do it for you, upload parameters. And have it export back to your server.
In response to Leur
I considered that, but it'd be nice if there was a less hacksy method to do something relatively simple.

I think I will have to resort to it though, 'cause there seems to be no easy DM method to use.
In response to Murrawhip
You could try suggesting it. They may add it if there isn't already a way to do this, and it is helpful to people.
In response to Leur
I made that a while ago. Maybe it'll help.

convertTime(n as num)
var/secs=floor(n/10)
var/mins=floor(secs/60)
secs-=mins*60
var/hours=floor(mins/60)
mins-=hours*60
var/days=floor(hours/24)
hours-=days*24
var/weeks=floor(days/7)
days-=weeks*7
var/t
if(weeks)t+="[weeks] weeks "
if(days||weeks)t+="[days] days "
if(hours||days||weeks)t+="[hours] hours "
if(hours||days||weeks||mins)t+="[mins] minutes and [secs] seconds"
else t+="[secs] seconds"
return t


#Edit you also need my floor proc...

    floor(A,B=1)
if(A==null||!isnum(A)||B==null||!isnum(B))
world.log<<"Invalid Parameters\[[A==null?"No A":""],[B==null?"No B":""]]"
return 0
var/initA=A
while(A>=B)A-=B
return round(initA,B)-(A<B/2?0:B)
In response to Tubutas
I believe he is asking is it possible to create a timestamp from providing some information about which date he specified since the example on php's website is...(below), which in this case would be no.

if (($timestamp = strtotime($str))
In response to Leur
I guess I was just determining whether or not there was already a way to do this- not wanting to add a low quality post to the Request a Feature page.

I 'spose I'll request it and see how it goes.

----
EDIT

Well- it's posted: http://www.byond.com/members/ DreamMakers?command=view_tracker_issue&tracker_issue=1619

I'm still hoping for an easier solution though :D
In response to Tubutas
No idea what you're doing with that floor proc. A more straightforward one is:

#define ceil(X,Y) -round(-(X)-(Y)/2,(Y))
#define floor(X,Y) round((X)-(Y)/2,(Y))