#pragma once #include #include #include #include #include namespace timeutil { inline std::wstring to_string(const time_t time) { return std::to_wstring(static_cast(time)); } inline std::optional from_string(const std::wstring& s) { try { uint64_t i = std::stoull(s); return static_cast(i); } catch (...) { return std::nullopt; } } inline std::time_t now() { return winrt::clock::to_time_t(winrt::clock::now()); } namespace diff { inline int64_t in_seconds(const std::time_t to, const std::time_t from) { return static_cast(std::difftime(to, from)); } inline int64_t in_minutes(const std::time_t to, const std::time_t from) { return static_cast(std::difftime(to, from) / 60); } inline int64_t in_hours(const std::time_t to, const std::time_t from) { return static_cast(std::difftime(to, from) / 3600); } inline int64_t in_days(const std::time_t to, const std::time_t from) { return static_cast(std::difftime(to, from) / (3600 * 24)); } } }