diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-12-04 18:29:42 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-12-04 20:02:50 +0100 |
commit | abafb52f37beb5659efc2105ccd1568e1f754898 (patch) | |
tree | 6a60636d3497560ca61e5aae5f6d7061c4f18553 /src/mbgl/util/time.cpp | |
parent | bff6aeb4da41dee1f5f1cfa0be81b6c257257253 (diff) | |
download | qtlocation-mapboxgl-abafb52f37beb5659efc2105ccd1568e1f754898.tar.gz |
make most headers private
Diffstat (limited to 'src/mbgl/util/time.cpp')
-rw-r--r-- | src/mbgl/util/time.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mbgl/util/time.cpp b/src/mbgl/util/time.cpp new file mode 100644 index 0000000000..1953975b18 --- /dev/null +++ b/src/mbgl/util/time.cpp @@ -0,0 +1,25 @@ +#include <mbgl/util/time.hpp> +#include <mbgl/util/uv_detail.hpp> + +namespace mbgl { +namespace util { + +timestamp now() { + return uv_hrtime(); +} + +static const char *week[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; +static const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + +std::string rfc1123(std::time_t time) { + std::tm info; + gmtime_r(&time, &info); + char buffer[30]; + snprintf(buffer, 30, "%s, %02d %s %4d %02d:%02d:%02d GMT", week[info.tm_wday], info.tm_mday, + months[info.tm_mon], 1900 + info.tm_year, info.tm_hour, info.tm_min, info.tm_sec); + return buffer; +} + +} +} |