Files
MapLibreParticleLab/src/util/time.cpp
2014-11-04 06:44:50 -08:00

26 lines
699 B
C++

#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;
}
}
}