2022-06-08 23:25:50 +02:00
|
|
|
#ifndef OPENMW_COMPONENTS_MISC_TIMECONVERT_H
|
|
|
|
#define OPENMW_COMPONENTS_MISC_TIMECONVERT_H
|
|
|
|
|
2022-06-11 23:38:09 +02:00
|
|
|
#include <ctime>
|
|
|
|
#include <chrono>
|
|
|
|
|
2022-06-08 23:25:50 +02:00
|
|
|
namespace Misc
|
|
|
|
{
|
2022-06-11 23:38:09 +02:00
|
|
|
template <typename TP>
|
|
|
|
inline std::time_t to_time_t(TP tp)
|
2022-06-08 23:25:50 +02:00
|
|
|
{
|
2022-06-11 23:38:09 +02:00
|
|
|
using namespace std::chrono;
|
|
|
|
auto sctp = time_point_cast<system_clock::duration>(tp - TP::clock::now() + system_clock::now());
|
|
|
|
return system_clock::to_time_t(sctp);
|
2022-06-08 23:25:50 +02:00
|
|
|
}
|
|
|
|
} // namespace Misc
|
|
|
|
|
|
|
|
#endif
|