does anyone know some date&time subtraction algo?
what i what to do: enter two dates with exact time (for example 2001 3 31 17:59:59 and 2002 5 1 15:21/3) and get the difrence of the those dates in secs ('couse the smallest unit here is scond).
i've tried to figure it out but i've must be to dumb or tired couse can't came out with anything :(

THX and CYA
Posted on 2002-05-01 08:20:39 by NEMO
Others have converted both dates to Julian format
which makes substraction simplier, iirc.
Posted on 2002-05-01 08:28:36 by bitRAKE
Posted on 2002-05-01 09:27:28 by bazik
taken from the win32.hlp (SYSTEMTIME):
It is not recommended that you add and subtract values from

the SYSTEMTIME structure to obtain relative times.
Instead, you should

? Convert the SYSTEMTIME structure to a FILETIME structure.
? Copy the resulting FILETIME structure to a LARGE_INTEGER structure.
? Use normal 64-bit arithmetic on the LARGE_INTEGER value.
I hope it helps
Posted on 2002-05-01 09:31:08 by savage
This will do what savage suggested:



system_time SYSTEMTIME <> ;used to gather current time
time_1 FILETIME <> ;used to gather beginning time
time_2 FILETIME <> ;used to gather ending time
elaps_time FILETIME <> ;used to hold elapsed time


invoke GetLocalTime, addr system_time
invoke SystemTimeToFileTime, addr system_time, addr time_1

;Wait 10 seconds
invoke GetLocalTime, addr system_time
invoke SystemTimeToFileTime, addr system_time, addr time_2

;Subtract time_2 from time_1 to calculate the number of 100 nanoseconds elapsed
mov eax, time_1.dwLowDateTime
sub eax, time_2.dwLowDateTime
mov elaps_time.dwLowDateTime, eax

mov eax, time_1.dwHighDateTime
sbb eax, time_2.dwHighDateTime
mov elaps_time.dwHighDateTime, eax ;elaps_time now contains # of 100 nanoseconds elapsed


HTH
farrier
Posted on 2002-05-03 10:55:06 by farrier
thanx for reply........ and look at that, there's an clean math way to done this and i wanted to check every year, mounth, day, etc.

thanks again
Posted on 2002-05-03 17:19:56 by NEMO
can anybody point me to some tuts about 64-bit math in asm. i need to learn how to convert it to seconds and then disply how to display the answer in edit box, but until i will not know how to do this it's not gonne be easy :grin:
so if U know some tuts, please help
Posted on 2002-05-04 11:56:16 by NEMO
NEMO,

The attached file contains a few procedures from
my AlarmClock/Timer/Stopwatch program, in
Masm32\Example8\jacts

It's not optimized, or pretty but it works on my
Win95 machines.

Any questions, let me know!

The update_diplay proc updates the status bar with
0 :Hours 15 :Minutes 32 :Seconds

hth

farrier
Posted on 2002-05-08 16:54:34 by farrier