mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Put json time as unix time.
This commit is contained in:
@@ -22,6 +22,7 @@ int iToSeconds(boost::posix_time::ptime ptWhen)
|
||||
: (ptWhen-ptEpoch()).total_seconds();
|
||||
}
|
||||
|
||||
// Convert our time in seconds to a ptime.
|
||||
boost::posix_time::ptime ptFromSeconds(int iSeconds)
|
||||
{
|
||||
return iSeconds < 0
|
||||
@@ -29,6 +30,18 @@ boost::posix_time::ptime ptFromSeconds(int iSeconds)
|
||||
: ptEpoch() + boost::posix_time::seconds(iSeconds);
|
||||
}
|
||||
|
||||
// Convert from our time to UNIX time in seconds.
|
||||
uint64_t utFromSeconds(int iSeconds)
|
||||
{
|
||||
boost::posix_time::time_duration tdDelta =
|
||||
boost::posix_time::ptime(boost::gregorian::date(2000, boost::gregorian::Jan, 1))
|
||||
-boost::posix_time::ptime(boost::gregorian::date(1970, boost::gregorian::Jan, 1))
|
||||
+boost::posix_time::seconds(iSeconds)
|
||||
;
|
||||
|
||||
return tdDelta.total_seconds();
|
||||
}
|
||||
|
||||
//
|
||||
// Hex suport
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user