From the wxWidgets online docs, it seems that there is no direct way to create a wxDateTime directly from a wxLongLong
value as returned e.g. from wxGetUTCTimeMillis
or wxGetLocalTimeMillis
. Hence I wonder
- if there is some obscure reason for this omission and
- if the code below is the formally correct way to do it (or relies too much on assumptions about the underlying types or misses some obscure time zone or leap second considerations or ...).
OK, I do have a suspicion about 1.: We also have wxGetUTCTimeUSec()
and so the "naked" wxLongLong
does not tell it it is measured in milli- or microseconds. But still ...
#include <wx/time.h>
wxLongLong myMillis = wxGetUTCTimeMillis()
...
#include <wx/datetime.h>
wxDateTime myDateTime;
myDateTime.Set( (time_t)((myMillis/1000).ToLong()) );
myDateTime.SetMilliSecond( (unsigned short)((myMillis % 1000).ToLong()) );