Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert from MFC's COleDateTime to C# DateTime?

I have an older library that uses COleDateTime as a return type in a C++ MFC Dll. When I do a PInvoke, can I marshal that with confidence to a DateTime object? Or should I do something wacky, like convert the COleDateTime into the number of ticks since 1970, and then convert those ticks back to a DateTime object in the C# calling project?

Thanks!

like image 959
mmr Avatar asked Dec 22 '22 12:12

mmr


1 Answers

You can return a double, by accessing the m_dt member on the COleDateTime class.

Then, you would pass that double to the static FromOADate method on the DateTime structure to convert the double to a DateTime instance.

like image 110
casperOne Avatar answered Jan 05 '23 10:01

casperOne