GMT time...

BlitzMax Forums/BlitzMax Beginners Area/GMT time...

degac(Posted 2007) [#1]
I think this is the strangest question ever made on this forum....How I can check (via Bmax) the 'local time', I mean the offset by GMT?
For example in Italy the GMT is +1...
I have a little problem when I try to convert the timestamp to a 'human' time...
Thanks in advance


Dreamora(Posted 2007) [#2]
Ask via API what timezone the user choose.


ImaginaryHuman(Posted 2007) [#3]
Or ask the user yourself what timezone they're in.


degac(Posted 2007) [#4]
Ok. thanks


Brucey(Posted 2007) [#5]
There are various API calls available on all the platforms for finding out this kind of information.

Google is your friend ;-)


degac(Posted 2007) [#6]
Hi, after digging in Internet for 2 days...


I can recover (from GetLocalTime) only the GMT (what I'm looking for) but the others info are not correctly interpreted...Well at last it works!!!!
My only problem is: there is another syntax for using API (extern and end extern), but I have encounterd too much error...maybe it's due to the 'size' of the parameters I passed to the functions...

When I have a little time I'm starting digging again to find info for the Mac version....


Gabriel(Posted 2007) [#7]
What's the @@ after the fields of TSYSTEMTIME? Is tha the quick way of declaring a short? ( It's not listed as such in the docs, but that's no guarantee. )


degac(Posted 2007) [#8]
Yes @@ --> :short, I found this after digging for 2 days...(and after many trial&errors...) I'm not a C++ expert so many C structures refers to word, uword, char & so on...It's a pain for my little brain


Sub_Zero(Posted 2007) [#9]
Handy code.

Yes @@ --> :short, I found this after digging for 2 days...(and after many trial&errors...) I'm not a C++ expert so many C structures refers to word, uword, char & so on...It's a pain for my little brain

You'll get used to it :)


Perturbatio(Posted 2007) [#10]
Speaking of C, could you not do a multi-platform version with these?
(not sure if the declarations are exactly right, I can't quite get it working properly)

Type tm
	Field tm_sec:Int
	Field tm_min:Int
	Field tm_hour:Int
	Field tm_mday:Int
	Field tm_mon:Int
	Field tm_year:Int
	Field tm_wday:Int
	Field tm_yday:Int
	Field tm_isdst:Int
	Field tm_gmtoff:Long
	Field tm_zone:Byte Ptr
End Type


Type time_t
	Field hour:Byte
	Field minute:Byte
	Field second:Byte
	Field hsecond:Byte
End Type

Extern "C"
	Function localtime:tm(time:Byte Ptr) = "localtime"
	Function time:time_t(time:Byte Ptr) = "time"
End Extern



klepto2(Posted 2007) [#11]
Maybe you could use this:
http://klepto2.kl.funpic.de/include.php?path=content/download.php&contentid=14&download=go

It is a ext Time Module which now also supports Microunix time
and it is easy to use.


Yan(Posted 2007) [#12]
Import pub.stdc

Extern "C"
	Function gmtime_:Byte Ptr(time:Byte Ptr) = "gmtime"
End Extern

Local calendarTime[1], buff:Byte[256]

time_(calendarTime)

strftime_(buff, buff.length, "%A %d %B %Y - %H:%M:%S (%Z)", localtime_(calendarTime))
Print String.FromCString(buff)

strftime_(buff, buff.length, "%A %d %B %Y - %H:%M:%S", gmtime_(calendarTime))
Print String.FromCString(buff) + " (GMT Standard Time)"

??


degac(Posted 2007) [#13]
wtf!!! all this work for something there is already?!??! arghhhhhhhh.....
:(
well something new to understand, thanks anyway.


Sub_Zero(Posted 2011) [#14]
what about getting the current unix timestamp for current time??
I mean without writing a temporary file and then filetime it to get the current timestamp.....

Any ideas anyone?

Last edited 2011


Sub_Zero(Posted 2011) [#15]
bump


TaskMaster(Posted 2011) [#16]

Extern "c"
	Function time(timer:Byte Ptr)
End Extern

debuglog time(Null)



Last edited 2011


Yan(Posted 2011) [#17]
In the above code, calenderTime *is* unix time*...
unixTime = time_(Null)
...OR...
time_(Varptr(unixTime))


*I just used a weird ass method of getting a integer pointer. :o|


[edit]
Taskmaster beat me to it...That's what happens when you try to post whilst watching 'Robinson Crusoe On Mars' on youtube. ;o)
[/edit]

Last edited 2011


Sub_Zero(Posted 2011) [#18]
Thanks alot... for those nifty little tips ;-)