News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Current time plus X seconds - simple example

Started by jj2007, September 20, 2015, 08:07:45 PM

Previous topic - Next topic

jj2007

GetTimePlusX works with plain Masm32, but you will need a replacement for MasmBasic's fTime$() macro:

include \masm32\MasmBasic\MasmBasic.inc      ; download
.code
GetTimePlusX proc xtra
LOCAL stime:SYSTEMTIME, ftime:FILETIME
  invoke GetLocalTime, addr stime
  invoke SystemTimeToFileTime, addr stime, addr ftime
  fild xtra                  ; put xtra into ST(0)
  fmul FP4(10000000.0)       ; convert to seconds (i.e. adjust for 100-nanosecond intervals)
  fild qword ptr ftime
  fadd
  fistp qword ptr ftime
  movlps xmm0, ftime
  ret
GetTimePlusX endp

  Init
  PrintLine fTime$()             ; current time
  invoke GetTimePlusX, 1800      ; plus 30 minutes
  PrintLine fTime$(xmm0)
  invoke GetTimePlusX, 3600*5    ; plus 5 hours
  PrintLine fTime$(xmm0)
  Exit

end start

Output:
12:00:14
12:30:14
17:00:14

ragdog


dedndave

        INCLUDE    \Masm32\Include\Masm32rt.inc

        .DATA?
        ALIGN   4

fts     FILETIME <>
sts     SYSTEMTIME <>
buf     db 32 dup(?)

        .CODE

main    PROC

;get the local time in a SYSTEMTIME structure

        INVOKE  GetLocalTime,offset sts

;format the time for display, and show it

        INVOKE  GetTimeFormat,LOCALE_USER_DEFAULT,TIME_FORCE24HOURFORMAT or TIME_NOTIMEMARKER,
                offset sts,NULL,offset buf,sizeof buf
        print   offset buf,13,10

;convert SYSTEMTIME to FILETIME

        INVOKE  SystemTimeToFileTime,offset sts,offset fts

;add 1 minute

        add     fts.dwLowDateTime,600000000  ;1 minute, in 100 nS steps
        adc     fts.dwHighDateTime,0

;convert FILETIME to SYSTEMTIME

        INVOKE  FileTimeToSystemTime,offset fts,offset sts

;format the time for display, and show it

        INVOKE  GetTimeFormat,LOCALE_USER_DEFAULT,TIME_FORCE24HOURFORMAT or TIME_NOTIMEMARKER,
                offset sts,NULL,offset buf,sizeof buf
        print   offset buf,13,10

        print   chr$(13,10)
        inkey
        INVOKE  ExitProcess,0

main    ENDP

        END     main

herge


Hello Jochen & Dave:

If we use an offset of say UTC -12 or UTC -14
we could have all positive offsets.
We could be sneaky and pound out 24 hours from UTC-12
in one hour intervals. If we use an offset of (systemtime+15),or
filetime+15, you would have daylight savings time?
I am assuming of course that daylight savings time is plus one hour
over standard time. We still have N Korea, Venezuela, India, Nepal
and Newfoundland and some Australian states that are half hour
and of course New Zealand's Chatham islands +45 minutes.

Regards Herge
Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.

dedndave

rather than do that, use a time zone near the international date line as the base-zone   :biggrin:

rrr314159

Quote from: herge... of course New Zealand's Chatham islands +45 minutes.

- of course! everybody knows that :P
I am NaN ;)

dedndave

in days past, many areas in Russia used 15 minute increments (and other parts of Eurasia)
i seem to recall that some even had 20 and 40 - but, i can't find any historical info to support that

the only reason i know anything about it is ham radio - lol
i got my first license at age 12 (early 1968), so i've noticed a few changes

TWell

Now russian have 1 hour intervals. Least here
That CCCP (sssr) time is over :t

herge

Good Afternoon TWell:

Just Google "Time in Wherever"
where Wherever is a city or country you
are intrested in.

Regards Herge
Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.

herge


Good Morning Dave:

https://en.wikipedia.org/wiki/International_Date_Line

UTC-12 or UTC+12 will get you near the international date line.

Regards Herge
Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.