Latest Uploads Mutant Mon ... (Blitz3D)steve_ancell Mutant Mon ... r package.steve_ancellimage-13-0 ... -01-38.jpgJayenkai Mutant Monty Remakesteve_ancellhai.jpgCodersRuleSillyAddition.pngJayenkai
 Code Snippets > Timing ( Created 17 January 2010 | Last Edited 17 January 2010)

 Timestamp by Jayenkai | No Votes Written inBlitz Max Why doesn't BlitzMax have a timestamp?! This oughta work for most stuff.. Doesn't keep mills, but they're addable if you're bored. Function Timestamp:Long() ' Returns a big-ass number. fLong:Long=0 ftxt\$=CurrentDate\$() ftxt\$=Upper\$(ftxt\$) 'DD MON YYYY '12345678901 yr=Abs(Int(Mid\$(ftxt\$,8,4))) mon=0 Select Mid\$(ftxt\$,4,3) Case "JAN" mon=1 Case "FEB" mon=2 Case "MAR" mon=3 Case "APR" mon=4 Case "MAY" mon=5 Case "JUN" mon=6 Case "JUL" mon=7 Case "AUG" mon=8 Case "SEP" mon=9 Case "OCT" mon=10 Case "NOV" mon=11 Case "DEC" mon=12 End Select day=Abs(Int(Mid\$(ftxt\$,1,2))) ftxt\$=CurrentTime\$() 'HH:MM:SS '12345678 hr=Abs(Int(Mid\$(ftxt\$,1,2))) mn=Abs(Int(Mid\$(ftxt\$,4,2))) sc=Abs(Int(Mid\$(ftxt\$,7,2))) ml=(MilliSecs() Mod 1000); If ml<0 Then ml=1000+ml flong=Long(Long(yr)*12*31*24*60*60)+Long(Long(mon)*31*24*60*60)+Long(Long(day)*24*60*60)+Long(Long(hr)*60*60)+Long(Long(mn)*60)+Long(sc) Return flong End Function Function StampTime\$(time:Long) ' Returns HH:MM:SS from big-ass number ftxt\$=Right\$("00"+(time Mod 60),2) time=time/60 ftxt\$=Right\$("00"+(time Mod 60),2)+":"+ftxt\$ time=time/60 ftxt\$=Right\$("00"+(time Mod 24),2)+":"+ftxt\$ time=time/24 Return ftxt\$ End Function Function StampDate\$(time:Long) ' Returns DD-MM-YYYY from big-ass number time=time/60 time=time/60 time=time/24 ftxt\$=Right\$("00"+(time Mod 31),2) time=time/31 ftxt\$=ftxt\$+"-"+Right\$("00"+(time Mod 12),2) time=time/12 ftxt\$=ftxt\$+"-"+Right\$("00"+time,4) Return ftxt\$ End Function -->

Posted : Sunday, 17 January 2010, 10:54
Afr0

FFS

Classes Jay, use classes!

Posted : Sunday, 17 January 2010, 11:51
JL235

Afro FFS

Classes Jay, use classes!

For something this simple, I disagree. They are utility functions that don't preserve state between calls. Why do they need to be in their own class? Their own file or module is enough to seperate them out from the rest of the application or library.

However I would say that you should be aware that different users will generate different timestamps because of timezone differences. So essentially only rely on this for local stuff, don't rely on it for say a scoreboard!

Posted : Sunday, 17 January 2010, 11:58
Jayenkai

Yeah, I've currently decided against online scores, since.. well, it's all kinda mangled up at the minute.

And, these aren't "Unix" timestamps, they're just bog-standard ones, but they are 100% reusable, and as such, completely worthwhile having!!

. and, in fact, they ARE for a local scoreboard, so you can flick through a nice graph, with all your previous scores on it..
Mmmmmm....
Graph!!!

Posted : Sunday, 17 January 2010, 16:10
Afr0

I just noticed you're generating big-ass numbers.
Might wanna look into Big Integers.

Posted : Sunday, 17 January 2010, 16:31
JL235

He's using longs, which is standard for holding time values.

In what way would big integers be more appropriate?

|edit| When I said don't use them for a score board, I meant for an online scoreboard. |edit|

Posted : Sunday, 17 January 2010, 16:40
Jayenkai

It shouldn't ever hit anything too big.
Or at least, not until the year 10000, (he says, giving it a run through) whereby the 4 digit display thing kinda starts to limit the year number.

Posted : Monday, 18 January 2010, 10:19
Jayenkai

I've not got to the stage of messing with mods yet. At the minute, I'm trying to keep everything "Code Only", so I know it'll (should!) run on all 3 main targets without all the faffing about.

The number of Blitz things that have been broken, 'cos I've lost track of certain versions of specific userlibs, or because I updated one userlib, and it broke something else..
It's completely insane, so I'm trying to keep things in the code folder as much as possible.

Maybe later!!

Posted : Monday, 18 January 2010, 15:03
Jayenkai

Would that happily work on all 3 targets? (Win/Linux/Mac)
I'm being very very aware of completely screwing this up, and am taking baby steps so I know what broke it all!

(although I've still no mac to test with, so it'll all come crashing down anyway!!)

Posted : Monday, 18 January 2010, 21:08
mindstorm8191

Or at least, not until the year 10000,

You'd better fix that now, Jay, or else it'll be Y2K all over again! lol

Posted : Tuesday, 19 January 2010, 02:56
Jayenkai

I've lived with the Millisecs thing for so long, avoiding it is second nature, especially when dealing with the whole wraparound thing. (does it still do that?)

OK, I'll have a piss about with this stuff later.
Today's task is to get this test engine finished, and uploaded for people to try out.
Using "Test Engine" as "AGameAWeek"..
Only if it's good enough!!

 Latest PostsMutant Monty update. steve_ancell Wed 09:41 Android Dev Test Doohickey Jayenkai Tue 09:58 Aminal Xing Knew Leef Jayenkai Tue 04:25 Spark dna Mon 17:24 HoboTile steve_ancell Sun 10:07 Hoover steve_ancell Sat 21:53 Scrabble Rabble Jayenkai Fri 08:13 Not Fit for Purpose Jayenkai Thu 20:29 Happy Birthday, Krakatomato steve_ancell Thu 18:03 How Deep is Your Code? Hotshot Thu 14:35 More

 Latest Items Blog : Snow WorklogCower Mon 12:23 Dev-Diary : Mutant Monty: Amstrad CPC to Windows conversionsteve_ancell Sat 19:12 Showcase : MLG : Microscopic Lifeform Genociderockford Wed 09:24 News : Newsletter #176Jayenkai Sat 04:49 News : Newsletter #175Dabz Tue 09:38 Blog : Snow: More Material JunkCower Sat 23:17 Techy : AppleTVJayenkai Thu 09:40 Blog : Graphvizsteve_ancell Sat 14:17 Pets : Top-Down Shadow HackJayenkai Tue 05:52 Snippet : JNKrunch v1.0Jayenkai Sat 07:20 News : Newsletter #173waroffice Fri 04:47 Blog : Material LoadingCower Fri 02:08 Pets : I Done Won A Thingshroom_monk Sun 11:31 Pets : Repurposing A LexerCower Mon 22:06 Bah : Feeling a Little Angryspinal Mon 11:26More

Who's Online
shroom_monk
Thu, at 01:28
spinal
Thu, at 01:10
therevillsgames
Thu, at 01:10
CodersRule
Wed, at 23:23
Dabz
Wed, at 22:34
Evil Roy Ferguson
Wed, at 21:24
dna
Wed, at 20:23
steve_ancell
Wed, at 19:36
Jayenkai
Wed, at 18:28