flat assembler
Message board for the users of flat assembler.

Index > Main > how to get date and time during compilation

Author
Thread Post new topic Reply to topic
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 14 Jun 2011, 20:50
Sorry if this question was asked many times but did not find in FASM manual and not in search MAIN.

How can I obtain date and time information during compilation ?
I want to build a date/time string of compilation date like

yyyymmddhhmmss

Something like that.
Does ist exist ?

Shocked

Thanks, Tom
Post 14 Jun 2011, 20:50
View user's profile Send private message Send e-mail Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 14 Jun 2011, 20:53
the easy way would be to do it by hand, with a pencil on a sheet of paper.
for the hard way, i don't have ideas, wait for experts to have a better answer.

all in all, i like my answer, i find it cool.
Post 14 Jun 2011, 20:53
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 14 Jun 2011, 20:54
Using windows...

Code:

_st SYSTEMTIME 

push _st
call [GetLocalTime]

mov eax,_st

[eax+SYSTEMTIME.wDay]  => Day | ie Monday, Tuesday..etc
[eax+SYSTEMTIME.wDate] => Date
[eax+SYSTEMTIME.wHour] => Hour
....
or

[_st.wXXX]

    


--------------------------edited


Last edited by typedef on 14 Jun 2011, 23:22; edited 1 time in total
Post 14 Jun 2011, 20:54
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 14 Jun 2011, 20:56
Okay typedef, how can windows obtain the compilation date / time of binary compiled by FASM ?
Post 14 Jun 2011, 20:56
View user's profile Send private message Send e-mail Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 14 Jun 2011, 20:58
search the forum, there were several macros for it.

PS: At first I saw topic "how to get date during compilation", then I was disappointed Very Happy
Post 14 Jun 2011, 20:58
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 14 Jun 2011, 21:04
okay for any non specific date you can try http://www.dia.com
Post 14 Jun 2011, 21:04
View user's profile Send private message Send e-mail Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 14 Jun 2011, 22:01
You can use the built in %t timestamp:
Code:
_t = %t

_t_s =  _t mod 60
_t_m = ((_t - _t_s) / 60) mod 60
_t_h = ((_t - (_t_m * 60) - _t_s) / 3600) mod 24

db '0'+(_t_h  /  10)
db '0'+(_t_h mod 10)
db ':'
db '0'+(_t_m  /  10)
db '0'+(_t_m mod 10)
db ':'
db '0'+(_t_s  /  10)
db '0'+(_t_s mod 10)
    
You should be able to get the date form this as well.
Post 14 Jun 2011, 22:01
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 14 Jun 2011, 22:09
typedef wrote:
Using windows...

Code:

SYSTEMTIME st

push st
call [GetLocalTime]

mov eax,st

[eax+SYSTEMTIME.wDay]  => Day | ie Monday, Tuesday..etc
[eax+SYSTEMTIME.wDate] => Date
[eax+SYSTEMTIME.wHour] => Hour
....

    

Sorry to interfere but i must correct your code...

1) st is reserved FPU register, it must have new name (eg: _st)
2) Name goes before struct type (eg: _st SYSTEMTIME)
3) No need to use EAX (eg: [_st.wDay] is simpler)

Just thought i would help (to keep OP from chasing ghosts) Smile

_________________
Coding a 3D game engine with fasm is like trying to eat an elephant,
you just have to keep focused and take it one 'byte' at a time.
Post 14 Jun 2011, 22:09
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 14 Jun 2011, 22:26
cod3b453 wrote:
You can use the built in %t timestamp:
Code:
_t = %t

_t_s =  _t mod 60
_t_m = ((_t - _t_s) / 60) mod 60
_t_h = ((_t - (_t_m * 60) - _t_s) / 3600) mod 24

db '0'+(_t_h  /  10)
db '0'+(_t_h mod 10)
db ':'
db '0'+(_t_m  /  10)
db '0'+(_t_m mod 10)
db ':'
db '0'+(_t_s  /  10)
db '0'+(_t_s mod 10)
    
You should be able to get the date form this as well.


Thank you for that code snippet.
I tried myself with %t.
Is not comfortable because have to write own macro but now I have following problem.

My computer dumps out date/time at GMT.
There is a difference of 2 hours to Berlin time because of other timezone and DST (daylight saving time) active.

So my computer writes 14.06.2011 22:25:00.
Of course when I look at my PC clock it is 15.06.2011 00:25:00

Any idea to solve this problem ? Shocked

Should I open a new thread with this more specific problem ? Very Happy
Post 14 Jun 2011, 22:26
View user's profile Send private message Send e-mail Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 14 Jun 2011, 22:34
You'd have to manually adjust the timestamp to your time zone and "daylight saving time" state. You can do this by simple arithmetic:
Code:
_t = %t + (+2 * 3600)    
Post 14 Jun 2011, 22:34
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 14 Jun 2011, 23:03
Okay but what happen when DST switched off ?
I now how I can manipulate data but thought there would be a more comfortable way.
Post 14 Jun 2011, 23:03
View user's profile Send private message Send e-mail Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 14 Jun 2011, 23:19
bitshifter wrote:
typedef wrote:
Using windows...

Code:

SYSTEMTIME st

push st
call [GetLocalTime]

mov eax,st

[eax+SYSTEMTIME.wDay]  => Day | ie Monday, Tuesday..etc
[eax+SYSTEMTIME.wDate] => Date
[eax+SYSTEMTIME.wHour] => Hour
....

    

Sorry to interfere but i must correct your code...

1) st is reserved FPU register, it must have new name (eg: _st)
2) Name goes before struct type (eg: _st SYSTEMTIME)
3) No need to use EAX (eg: [_st.wDay] is simpler)

Just thought i would help (to keep OP from chasing ghosts) Smile


Thank you bitshifter... I knew all that but I forgot because I just came HLL programming...lol Very Happy

you can see the way I declared system time

I forgot it's var DATA_TYPE

In C/C++/Java you know it's data_type var...

Sorry for that confusion and thank you bitshifter
Post 14 Jun 2011, 23:19
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 14 Jun 2011, 23:23
shutdownall wrote:
Okay typedef, how can windows obtain the compilation date / time of binary compiled by FASM ?


GetFileTime | http://msdn.microsoft.com/en-us/library/ms724320%28v=vs.85%29.aspx

?
Post 14 Jun 2011, 23:23
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 15 Jun 2011, 02:31
shutdownall, wouldn't be better to just stick with the GMT time (which is DST invariant)? The reason I have against local time is that when transitioning from DST back to normal time zone there are 60 minutes of a day that occurs twice, so you could end up with a latest compilation being "older" than a previous one (unless you add to your format a DST indicator).
Post 15 Jun 2011, 02:31
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.