diff options
Diffstat (limited to 'include/mbgl/util')
-rw-r--r-- | include/mbgl/util/chrono.hpp | 15 | ||||
-rw-r--r-- | include/mbgl/util/constants.hpp | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/include/mbgl/util/chrono.hpp b/include/mbgl/util/chrono.hpp index 8e0da1419a..81f05d610d 100644 --- a/include/mbgl/util/chrono.hpp +++ b/include/mbgl/util/chrono.hpp @@ -7,7 +7,6 @@ namespace mbgl { using Clock = std::chrono::steady_clock; -using SystemClock = std::chrono::system_clock; using Seconds = std::chrono::seconds; using Milliseconds = std::chrono::milliseconds; @@ -15,18 +14,22 @@ using Milliseconds = std::chrono::milliseconds; using TimePoint = Clock::time_point; using Duration = Clock::duration; -using SystemTimePoint = SystemClock::time_point; -using SystemDuration = SystemClock::duration; +// Used to measure second-precision times, such as times gathered from HTTP responses. +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()); +} + // Returns the RFC1123 formatted date. E.g. "Tue, 04 Nov 2014 02:13:24 GMT" -std::string rfc1123(SystemTimePoint); +std::string rfc1123(Timestamp); // YYYY-mm-dd HH:MM:SS e.g. "2015-11-26 16:11:23" -std::string iso8601(SystemTimePoint); +std::string iso8601(Timestamp); -SystemTimePoint parseTimePoint(const char *); +Timestamp parseTimestamp(const char *); // C++17 polyfill template <class Rep, class Period, class = std::enable_if_t< diff --git a/include/mbgl/util/constants.hpp b/include/mbgl/util/constants.hpp index 58f4143766..3517299df2 100644 --- a/include/mbgl/util/constants.hpp +++ b/include/mbgl/util/constants.hpp @@ -39,7 +39,7 @@ constexpr double MAX_ZOOM = 25.5; constexpr uint64_t DEFAULT_MAX_CACHE_SIZE = 50 * 1024 * 1024;; constexpr Duration DEFAULT_FADE_DURATION = Milliseconds(300); -constexpr SystemDuration CLOCK_SKEW_RETRY_TIMEOUT = Seconds(30); +constexpr Seconds CLOCK_SKEW_RETRY_TIMEOUT { 30 }; } // namespace util |