I'm porting some PHP to C++. Some of our database code stores time values as unix time stamps *100 The php contains code that looks a bit like this.
//PHP
static function getTickTime()
{
return round(microtime(true)*100);
}
I need something like this:
//C++
uint64_t getTickTime()
{
ptime Jan1st1970(date(1970, 1, 1));
ptime Now = microsecond_clock::local_time();
time_duration diff = Now - Jan1st1970;
return static_cast<uint64_t>(diff.total_seconds()*100);
}
Is something like this sensible? Is there a neater solution? Is there something nasty in this code that I can't see? (Guess I'm not experienced enough with boost::date_time to know these things)