1#pragma once
2
3#include <chrono>
4#include <string>
5
6namespace mbgl {
7
8using Clock = std::chrono::steady_clock;
9
10using Seconds = std::chrono::seconds;
11using Milliseconds = std::chrono::milliseconds;
12
13using TimePoint = Clock::time_point;
14using Duration = Clock::duration;
15
16// Used to measure second-precision times, such as times gathered from HTTP responses.
17using Timestamp = std::chrono::time_point<std::chrono::system_clock, Seconds>;
18
19namespace util {
20
21inline Timestamp now() {
22 return std::chrono::time_point_cast<Seconds>(t: std::chrono::system_clock::now());
23}
24
25// Returns the RFC1123 formatted date. E.g. "Tue, 04 Nov 2014 02:13:24 GMT"
26std::string rfc1123(Timestamp);
27
28// YYYY-mm-dd HH:MM:SS e.g. "2015-11-26 16:11:23"
29std::string iso8601(Timestamp);
30
31Timestamp parseTimestamp(const char *);
32
33Timestamp parseTimestamp(const int32_t timestamp);
34
35// C++17 polyfill
36template <class Rep, class Period, class = std::enable_if_t<
37 std::chrono::duration<Rep, Period>::min() < std::chrono::duration<Rep, Period>::zero()>>
38constexpr std::chrono::duration<Rep, Period> abs(std::chrono::duration<Rep, Period> d)
39{
40 return d >= d.zero() ? d : -d;
41}
42
43} // namespace util
44
45} // namespace mbgl
46

source code of qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/util/chrono.hpp