• Welcome to Valhalla Legends Archive.
 

Question

Started by DarkOne, April 27, 2003, 10:17 PM

Previous topic - Next topic

DarkOne

When performing a complete packet parse and retreiving the following:

Normal:
Record\SEXP\0\last game
Record\SEXP\0\last game result

Ladder:
Record\SEXP\1\last game
Record\SEXP\1\last game result

How do I convert the integer values recieved into the integer values used in showing the date and time of the last win, loss or draw?

For example:

NORMAL
WIN at 29556287 1363496298
WIN at 4/8/2003 22:25

If anyone can enlighten me, I'd appreciate it.

Skywing

#1
Quote from: DarkOne on April 27, 2003, 10:17 PM
When performing a complete packet parse and retreiving the following:

Normal:
Record\SEXP\0\last game
Record\SEXP\0\last game result

Ladder:
Record\SEXP\1\last game
Record\SEXP\1\last game result

How do I convert the integer values recieved into the integer values used in showing the date and time of the last win, loss or draw?

For example:

NORMAL
WIN at 29556287 1363496298
WIN at 4/8/2003 22:25

If anyone can enlighten me, I'd appreciate it.
These are the two members of a FILETIME structure.  The above link also includes suggestions on how to display such a structure in an easily understandable format.

Camel

if you're using vb, use this:
Public Function FTtoDate(str As String) As Date
   Dim D As Currency
   CopyMemory D, ByVal str, 8
   
   Const DateDiff = -109205 '"Win32 day 0;" CDbl(#1/1/1601#)
   Const TicksPerDay = 86400000# '60 * 60 * 24 * 1000
   
   On Error Resume Next
   FTtoDate = CDate(D / TicksPerDay + DateDiff)
   If ERR Then Debug.Assert False
End Function


that function expects the filetime as a stringamized qword, but you could easily adapt it
btw, currency is only used because it's 64bit

Camel

Quote from: Maddox on April 29, 2003, 01:05 AM
I suggest using FileTimeToLocalFileTime() then FileTimeToSystemTime().

my code is much shorter and more simple ;)

Skywing

#4
Quote from: Camel on April 29, 2003, 03:04 PM
Quote from: Maddox on April 29, 2003, 01:05 AM
I suggest using FileTimeToLocalFileTime() then FileTimeToSystemTime().

my code is much shorter and more simple ;)
Not really.  You still have to parse it out into days, hours, minutes, and so on with your method if you don't want to use the CDate format.  The SYSTEMTIME functions do this for you - and leave how exactly to present the information up to you.

Camel

#5
Quote from: Skywing on April 29, 2003, 03:33 PM
Quote from: Camel on April 29, 2003, 03:04 PM
Quote from: Maddox on April 29, 2003, 01:05 AM
I suggest using FileTimeToLocalFileTime() then FileTimeToSystemTime().

my code is much shorter and more simple ;)
Not really.  You still have to parse it out into days, hours, minutes, and so on with your method if you don't want to use the CDate format.  The SYSTEMTIME functions do this for you - and leave how exactly to present the information up to you.

what's wrong with CDate?

[edit] and, skywing, my function returns a vb Date, meaning you can display it however you want.

Yoni

You can display a SYSTEMTIME however you want, as well.

Camel

but it's far more practical in vb to use a Date