Reputation: 2177
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
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()) );
Upvotes: 1
Views: 713
Reputation: 1987
Actually you can. It is wxDateTime (time_t timet)
, described as seconds since the Epoch 00:00:00 UTC, Jan 1, 1970
.
The proof that this works (wxW 3.0.0):
wxDateTime wxDateTime::UNow()
{
return wxDateTime(wxGetUTCTimeMillis());
}
Upvotes: 3
Reputation: 241808
If it's just the current time you are interested in, there's also wxDateTime::UNow()
. But in general, I would agree with your assessment. One would think a wxLongLong
would be allowed from one of the constructors.
Upvotes: 0