flat assembler
Message board for the users of flat assembler.

Index > Windows > Timestamp

Author
Thread Post new topic Reply to topic
Evgeny



Joined: 16 Jan 2006
Posts: 11
Evgeny
How can I convert fasm timestamp (%t) to SYSTEMTIME?
Post 01 Apr 2006, 05:09
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
Here are macros that extract date and time from %t:

Code:
macro months [dayscount]
{
  forward
   if DAY > dayscount
    DAY = DAY-dayscount
    MONTH = MONTH+1
  forward
   end if
}

TIME = %T
DAY = TIME/(24*3600)

HOUR = (TIME - (DAY*24*3600))/3600
MINUTES = (TIME - DAY*24*3600 - HOUR * 3600)/60
SECONDS = TIME - DAY*24*60*60 - HOUR * 60*60 - MINUTES*60

DAY = DAY - (DAY+365)/(3*365+366)

YEAR = 1970+DAY/365
DAY = DAY mod 365 + 1
MONTH = 1

if YEAR mod 4 = 0
  FEBDAYS=29
else
  FEBDAYS=28
end if

months 31,FEBDAYS,31,30,31,30,31,31,30,31,30,31

macro num_to_db num, digits {
common
   local ..lbl, ..ptr, ..dig, ..num

..lbl:
   rb digits

   ..ptr = ..lbl + digits - 1
   ..num = num
   repeat digits
     ..dig = (..num mod 10) + $30
     ..num = ..num / 10
     store byte ..dig at ..ptr
     ..ptr = ..ptr - 1
   end repeat
}    


But if you need local time, you have to adjust %t before making calculations (for example my zone is GMT+2, so I'd have to add 2*3600 to %t). However if you'd like to have timezone-independed code , you should get system timezone using some API, then adjust %t and calculate at runtime.
Post 01 Apr 2006, 05:50
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
Post 01 Apr 2006, 09:10
View user's profile Send private message Visit poster's website Reply with quote
Evgeny



Joined: 16 Jan 2006
Posts: 11
Evgeny
Thank you.
Post 01 Apr 2006, 14:10
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.