Re: date Conversion Program in Assembly



Hi Ninad

Use this function i wrote:

; FILETIME structure
[St_DateTimeStamp:
St_DateTimeStamp.dwLowDateTime: D$ 0
St_DateTimeStamp.dwHighDateTime: D$ 0]



; SYSTEMTIME structure

[St_UTC:
St_UTC.wYear: W$ 0
St_UTC.wMonth: W$ 0
St_UTC.wDayOfWeek: W$ 0
St_UTC.wDay: W$ 0
St_UTC.wHour: W$ 0
St_UTC.wMinute: W$ 0
St_UTC.wSecond: W$ 0
St_UTC.wMilliseconds: W$ 0]



Proc TimeDateStampToString:
Arguments @TimeStamp, @DateFmt, @TimeFmt, @DateOut, @TimeOut

mov eax D@TimeStamp
mov edx &SECS_TO_100NS
mul edx


add eax &EPOCH_DIFF_SECS_INTERVAL_LOW
adc edx &EPOCH_DIFF_SECS_INTERVAL_HIGH


mov D$St_DateTimeStamp.dwLowDateTime eax
mov D$St_DateTimeStamp.dwHighDateTime edx

call 'kernel32.FileTimeToSystemTime' St_DateTimeStamp St_UTC

call 'KERNEL32.GetDateFormatA' &LOCALE_SYSTEM_DEFAULT &NULL
St_UTC D@DateFmt D@DateOut &MAX_UTC_TIME_LEN
call 'KERNEL32.GetTimeFormatA' &LOCALE_SYSTEM_DEFAULT &NULL
St_UTC D@TimeFmt D@TimeOut &MAX_UTC_TIME_LEN

EndP


Usage example:


[DataPointer: D$ ?] ; Points to the data that stored the value of the
timedate stamp.

[Sz_Year: B$ "yyyy/MM/dd ddd ",0]
[Sz_Hour: B$ "HH:mm:ss UTC",0]

[szDateString: B$ ? #64] ; Lenght of the date string. (Maximum is
&MAX_UTC_TIME_LEN)
[szTimeString: B$ ? #64] ; Lenght of the time string. (Maximum is
&MAX_UTC_TIME_LEN)


call TimeDateStampToString D$DataPointer Sz_Year Sz_Hour
szDateString szTimeString

Best Regards,

Guga

.



Relevant Pages

  • Re: Calculating elapsed time
    ... increments of days. ... that data to determine the amount of time elapsed since a particular ... Convert the SYSTEMTIME structure to a FILETIME structure. ... Copy the resulting FILETIME structure to a LARGE_INTEGER structure. ...
    (microsoft.public.vc.mfc)
  • Calculating elapsed time
    ... What is the best way to store a time value in a text file and then use that ... data to determine the amount of time elapsed since a particular operation ... Convert the SYSTEMTIME structure to a FILETIME structure. ... Copy the resulting FILETIME structure to a LARGE_INTEGER structure. ...
    (microsoft.public.vc.mfc)
  • Re: Calculating elapsed time
    ... CString csDay, csHour, csMinute, csSecond; ... Day1Diff.GetMinutes, (LPCTSTR) ... Convert the SYSTEMTIME structure to a FILETIME structure. ...
    (microsoft.public.vc.mfc)
  • Re: Strange time handling on files & folders
    ... Not sure exactly what you mean by translating a systemtime structure to a systemtime value ... It's up to you to track whether the FileTime structure you have is UTC or local and use the appropriate conversion call to switch to the other remembering that GetFileTime and SetFileTime are assuming that the values are UTC. ...
    (microsoft.public.vb.general.discussion)
  • Re: Calculating elapsed time
    ... CString csDay, csHour, csMinute, csSecond; ... Day1Diff.GetMinutes, (LPCTSTR) ... Convert the SYSTEMTIME structure to a FILETIME structure. ...
    (microsoft.public.vc.mfc)