mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
23 lines
496 B
C++
23 lines
496 B
C++
#include "utils.h"
|
|
|
|
boost::posix_time::ptime ptEpoch()
|
|
{
|
|
return boost::posix_time::ptime(boost::gregorian::date(2000, boost::gregorian::Jan, 1));
|
|
}
|
|
|
|
int iToSeconds(boost::posix_time::ptime ptWhen)
|
|
{
|
|
return ptWhen.is_not_a_date_time()
|
|
? -1
|
|
: (ptWhen-ptEpoch()).total_seconds();
|
|
}
|
|
|
|
boost::posix_time::ptime ptFromSeconds(int iSeconds)
|
|
{
|
|
return iSeconds < 0
|
|
? boost::posix_time::ptime(boost::posix_time::not_a_date_time)
|
|
: ptEpoch() + boost::posix_time::seconds(iSeconds);
|
|
}
|
|
|
|
// vim:ts=4
|