Jump to content

ColeDateTime (Solved)


pdvos
 Share

Recommended Posts

Hello,

Is here anybody who had to deal with ColeDateTime (https://learn.microsoft.com/en-us/cpp/atl-mfc-shared/reference/coledatetime-class?view=msvc-170)

I'm calling an ComObject and it returns the following double/unint64  1843356530524743552 but now I'm kinda stuck.

On a C forum somebody had a conversion and an tried converting it to autoit

Func _ConvertColeTime($Time)

$SecondsPerDay = 86400
$OffSetDays = 25569
$OffSetSeconds =  $OffSetDays * $SecondsPerDay
$UnixTime =  $Time * $SecondsPerDay - $OffSetSeconds

Return $UnixTime
EndFunc

But still no dice I'm very much out of my depth.

So is there anybody here who knows how to convert this or point me in the right direction?

 

Edited by pdvos
Link to comment
Share on other sites

Why don't you use one of the described methods to extract the needed data (hour, minute ...) from the ColeDateTime object?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hi water, thanks for your reply,

My peabrain simply can't grasp what is written there 😐

 

4676399042478430496 somehow translates to 21:36:15 (h,m,s) Am I suppose to split this up like?

year,month,day,hours,minutes,seconds,miliseconds

4676,39,90,42,47,84,30,496

But this also kinda doesn't make sense to me.  I'll have to study some more eventually I hope to figure it out :)

ty

Link to comment
Share on other sites

Please post the AutoIt script you have written.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

;~ It's used by internal software so can't show more than the actual function

Func _GetInfo($ApppName)
;~   STDMETHOD(AppInfo) (BSTR appName, DATE * Time ULONG* totalProcesses) ; <- from the C source

        Local $Time = DllStructCreate("UINT64")
        DllStructSetData($Time, 1, 0.0)
        Local $pTime = DllStructGetPtr($Time)

        ; VarGetType($pTime))   results in ptr
        
        Local $Process
        
        Local $oServerStatInfo = ObjCreate("Server.Info.10.1)
        $oServerStatInfo.AppInfo($ApppName, $pTime, $Process) ; AppInfo returns $pTime and $Process values
        
        Local $dTest = DllStructGetData($Time, 1)
        
        MsgBox(0, "", $dTest) ;  <- returns that double
        MsgBox(0, "", $Process) ;  <- this one works fine

    EndFunc   ;==>_GetInfo

;~ I know the objCreate part was successful because I get back the correct number of processes.
;~ And $dTest contains that double but maybe the way I handle the DLL stuff is wrong

So when I run the above function it returns for $dTest

4676399172631846851

and a second or two later
4676399172647754138

So as I can figure out it's keeping time

Edited by pdvos
Link to comment
Share on other sites

I haven't worked with DLL functions.
But I would have a look at the _Date* functions.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The only thing I'm thinking of is that you could drop the last 7 digits on the right because when you wrote...

So when I run the above function it returns for $dTest 
4676399172631846851 

and a second or two later
4676399172647754138

...then it appears that "a second or two later" is the difference between :

467639917263
467639917264

which could mean that the 7 other digits on the right are subdivisions of a second, in this case 1/100th of ns as found in documentation, for example on a web site :

Time values are measured in 100-nanosecond units called ticks, and a particular date is the number of ticks
since 12:00 midnight, January 1, 0001 A.D. (C.E.) in the GregorianCalendar calendar (excluding ticks
that would be added by leap seconds).
For example, a ticks value of 31241376000000000 represents the date, Friday, January 01, 0100 12:00:00 midnight. This is sometimes called "a moment in linear time".

Now as seen on this webpage :

1 Year (365.24 days) = 31556926 Seconds

Then let's drop 7 digits on the right => 3124137600 0000000

3124137600 / 31556926 = 99.00006 years, which is the difference between January 1, 0001 and January 01, 0100

Another example from the help file, topic _Date_Time_FileTimeToSystemTime , a bit reworked to display structures and work on a fixed date :

#include <Date.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIDiag.au3> ; for _WinAPI_DisplayStruct

Global $g_idMemo

Example()

Func Example()
    Local $tFile, $tSystem

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9,  $FW_NORMAL, $GUI_FONTNORMAL, "Courier New")
    GUISetState(@SW_SHOW)

    ; Encode a file time
    ; $tFile = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC)
    $tFile = _Date_Time_EncodeFileTime("11", "03", "2022", "01", "30", "15")

    _WinAPI_DisplayStruct($tFile, $tagFILETIME, "$tFile")
    Local $iLo = $tFile.Lo, $iHi = $tFile.Hi; lo => 3539676544   hi => 30994211

    Local $iQword = _WinAPI_MakeQWord($tFile.Lo, $tFile.Hi)
    ConsoleWrite("$iQword = " & $iQword & @crlf) ; 133119126150000000

    $tSystem = _Date_Time_FileTimeToSystemTime($tFile)
    _WinAPI_DisplayStruct($tSystem, $tagSYSTEMTIME, "$tSystem")

    MemoWrite("System file time .: " & _Date_Time_SystemTimeToDateTimeStr($tSystem))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Let's say we only got the Int64 of this script : 13311912615 0000000
Then we could apply the same calculation :

13311912615 / 31556926 = 421.8367420 years, which is the difference between the fixed date of the script (Nov 3, 2022) and January 1, 1601 because :

FILETIME structure
Contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).

So both Int64's studied before are valid. Unfortunately, this type of calculation doesn't seem to work on the Int64's you provided, then the mystery is still unsolved but who knows, maybe someone will be able to solve it (though I'm a bit perplexed when you presented in a post a number like 1843356530524743552 then in another post other numbers very different like 4676399042478430496)

Good luck :)

Link to comment
Share on other sites

I guess that the data format is the same as the DATE type: https://learn.microsoft.com/fr-fr/cpp/atl-mfc-shared/date-type?view=msvc-170 (sorry it seems the site switches to a localized page based on where you load it from.)

So forget the int64 representation, get the value as a double and try from there.

I'm always surprised by the various date/time proprietary and unpractical formats MS has invented out of thin air.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

4 minutes ago, jchd said:

I'm always surprised by the various date/time proprietary and unpractical formats MS has invented out of thin air.

I like that :D

Before I delete on my computer the following note...
Concerning timestamps : I'm posting the following example below because it's a bit related to this thread, maybe it could help other users facing a timestamp question. It's a personal example about a windows message timestamp that happened to me yesterday (based on real times) :

Computer boot on 02/11/2022 at 07h57m

Asked 2 consecutive windows msg at 23h09m00s (e.g 15h12m after boot) => 2 time stamps returned by windows :

54760 812
54760 953 (immediately after, so 812 and 953 are ms)

Waited 10s and asked 2 consecutive windows msg at 23h09m10s => time stamps returned :

54770 656
54770 750 (so 54770 and 54760 are seconds, separated by 10s)

 

54760s / 60s = 912.66666666 m
912.66666666m / 60m = 15.2111111 h = 15h + (about) 1/5h = 15h12m

So 15h12m has been retrieved from 54760s : this is the exact time difference between the computer boot time (07h57m) and windows time stamp 1st message (23h09m) . For what it's worth...

Link to comment
Share on other sites

Progress :)

 

Func _ReturnDateFromCOleDateTime($dColeDateDouble)

    Local $YR, $MN, $DD
    Local $iDaysToAdd = _DateToDayValue(1899, 12, 31)
    $Date = _DayValueToDate(Floor($dColeDateDouble) + $iDaysToAdd, $YR, $MN, $DD)

    Local $dAfterComma = $dColeDateDouble - (Floor($dColeDateDouble))

    Local $iSeconds = ($dAfterComma * 24) * 60 * 60
    Local $iHour = (Floor($iSeconds / 60 / 60))
    Local $iMinute = (Floor($iSeconds / 60) - ($iHour * 60))
    Local $iSecondsDisplay = (Floor($iSeconds - (($iMinute + ($iHour * 60)) * 60)))

    ConsoleWrite("Date:" & $YR & "-" & $MN & "-" & $DD & @CRLF)
    ConsoleWrite("Hours=" & $iHour & @CRLF)
    ConsoleWrite("Minutes=" & $iMinute & @CRLF)
    ConsoleWrite("Seconds=" & $iSecondsDisplay & @CRLF)

EndFunc   ;==>_ReturnDateFromCOleDate

First thing what had to be done wat get the double instead of the UINT64 - thank you jchd !!

This gave me the following double 44869.4435300926

the 44869 contained the date and the .4435300926 gave me the hours,minutes,second,ms


 _ReturnDateFromCOleDateTime(44869.4435300926)

Resulted in a human readable date/time :

Date:2022-11-05
Hours=10
Minutes=38
Seconds=41

Thank you water, pixelsearch and jchd !!

 

Link to comment
Share on other sites

  • pdvos changed the title to ColeDateTime (Solved)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...