summaryrefslogtreecommitdiff
path: root/src/mbgl/util/time.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/util/time.cpp')
-rw-r--r--src/mbgl/util/time.cpp25
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;
+}
+
+}
+}