diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/platform/time.hpp | 13 | ||||
-rw-r--r-- | include/mbgl/util/chrono.hpp | 4 |
2 files changed, 16 insertions, 1 deletions
diff --git a/include/mbgl/platform/time.hpp b/include/mbgl/platform/time.hpp new file mode 100644 index 0000000000..8769524514 --- /dev/null +++ b/include/mbgl/platform/time.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include <chrono> + +namespace mbgl { +namespace platform { + +// Returns the current time. Abstracted because some platforms +// will not allow direct access to the current time via syscall. +std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds> now(); + +} // namespace platform +} // namespace mbgl diff --git a/include/mbgl/util/chrono.hpp b/include/mbgl/util/chrono.hpp index 4de3c2d3a2..d736b4f826 100644 --- a/include/mbgl/util/chrono.hpp +++ b/include/mbgl/util/chrono.hpp @@ -1,5 +1,7 @@ #pragma once +#include <mbgl/platform/time.hpp> + #include <chrono> #include <string> @@ -19,7 +21,7 @@ using Timestamp = std::chrono::time_point<std::chrono::system_clock, Seconds>; namespace util { inline Timestamp now() { - return std::chrono::time_point_cast<Seconds>(std::chrono::system_clock::now()); + return platform::now(); } // Returns the RFC1123 formatted date. E.g. "Tue, 04 Nov 2014 02:13:24 GMT" |