A new class, CPowerTime, to easily work with date and time calculations.
Documentation:
https://github.com/JoseRoca/WinFBX/blob/master/docs/DateTime/CPowerTime%20Class.md
Thanks! Wilko
Awesome! Thanks so much.
I'm browsing through the class and thinking thoughts like, what if I have have a starting powertime and and ending powertime class how would I determine the difference between the two class instances. For example, let's say we want to profile a section of code or an algorithm. Maybe retrieve both using the GetFileTime property and do the difference calculation?
Yes. You can do:
DIM cpt AS CPowerTime
DIM cpt2 AS CPowerTime
cpt.Now
print "Press a key"
sleep
cpt2.Now
DIM nTime AS ULONGLONG = cpt2 - cpt
print nTime / CPowerTime_Millisecond
print nTime / CPowerTime_Second
print nTime
BTW there are two methods in the PowerBasic PowerTime object that I already haven't implemented: DateDiff and TimeDiff. Not sure how to code them.
I'm going to add these properties
' ========================================================================================
' Gets/sets the date and time as a FreeBasic date serial.
' ========================================================================================
PRIVATE PROPERTY CPowerTime.DateSerial () AS DOUBLE
DIM ft AS FILETIME
ft.dwLowDateTime = dwLowDateTime
ft.dwHighDateTime = dwHighDateTime
DIM dt AS DOUBLE, st AS SYSTEMTIME
FileTimeToSystemTime(@ft, @st)
SystemTimeToVariantTime @st, @dt
RETURN dt
END PROPERTY
' ========================================================================================
' ========================================================================================
PRIVATE PROPERTY CPowerTime.DateSerial (BYVAL dTime AS DOUBLE)
DIM st AS SYSTEMTIME
VariantTimeToSystemTime dTime, @st
DIM ft AS FILETIME
SystemTimeToFileTime @st, @ft
dwLowDateTime = ft.dwLowDateTime
dwHighDateTime = ft.dwHighDateTime
END PROPERTY
' ========================================================================================
They will allow to use CPowerTime with the FreeBasic date serial procedures, e.g.:
DIM ct AS CPowerTime
ct.DateSerial = DateSerial(2019, 2, 4)
Print Format(ct.DateSerial, "yyyy/mm/dd hh:mm:ss")
I have added these properties and reuploaded the zip file. Now we can use the FreeBasic DateSerial, DateValue, TimeValue, TimeSerial, Now and Format procedures with CPowerTime.
DIM ct AS CPowerTime
ct.DateSerial = DateSerial(2019, 2, 4)
ct.DateSerial = DateValue("4/2/2019")
ct.DateSerial = TimeValue("11:59:59PM")
ct.DateSerial = Now
ct.DateSerial = DateSerial(2005, 11, 28) + TimeSerial(7, 30, 50)
Print Format(ct.DateSerial, "yyyy/mm/dd hh:mm:ss")
Hola Josè
Thank you for your expansion. I already appreciated this under PowerBasic.
QuoteBTW there are two methods in the PowerBasic PowerTime object that I already haven't implemented: DateDiff and TimeDiff. Not sure how to code them.
I'm sure you can think a solution. :-))