@@ -140,7 +140,7 @@ int main(int argc, char* argv[]) { | |||||
#if defined ARCH_MAC | #if defined ARCH_MAC | ||||
INFO("Bundle path: %s", asset::bundlePath.c_str()); | INFO("Bundle path: %s", asset::bundlePath.c_str()); | ||||
#endif | #endif | ||||
INFO("System time: %lf", system::getUnixTime()); | |||||
INFO("System time: %s", string::formatTimeISO(system::getUnixTime()).c_str()); | |||||
// Load settings | // Load settings | ||||
settings::init(); | settings::init(); | ||||
@@ -79,6 +79,9 @@ Examples: | |||||
*/ | */ | ||||
std::vector<std::string> split(const std::string& s, const std::string& seperator, size_t maxTokens = 0); | std::vector<std::string> split(const std::string& s, const std::string& seperator, size_t maxTokens = 0); | ||||
std::string formatTime(const char* format, double timestamp); | |||||
std::string formatTimeISO(double timestamp); | |||||
#if defined ARCH_WIN | #if defined ARCH_WIN | ||||
/** Performs a Unicode string conversion from UTF-16 to UTF-8. | /** Performs a Unicode string conversion from UTF-16 to UTF-8. | ||||
@@ -1,3 +1,4 @@ | |||||
#include <ctime> | |||||
#include <cctype> // for tolower and toupper | #include <cctype> // for tolower and toupper | ||||
#include <algorithm> // for transform and equal | #include <algorithm> // for transform and equal | ||||
#include <libgen.h> // for dirname and basename | #include <libgen.h> // for dirname and basename | ||||
@@ -234,6 +235,18 @@ std::vector<std::string> split(const std::string& s, const std::string& separato | |||||
} | } | ||||
std::string formatTime(const char* format, double timestamp) { | |||||
time_t t = timestamp; | |||||
char str[1024]; | |||||
size_t s = std::strftime(str, sizeof(str), format, std::localtime(&t)); | |||||
return std::string(str, s); | |||||
} | |||||
std::string formatTimeISO(double timestamp) { | |||||
return formatTime("%FT%T%z", timestamp); | |||||
} | |||||
#if defined ARCH_WIN | #if defined ARCH_WIN | ||||
std::string UTF16toUTF8(const std::wstring& w) { | std::string UTF16toUTF8(const std::wstring& w) { | ||||
if (w.empty()) | if (w.empty()) | ||||