Convert logcat entry time to UTC before serializing

This commit is contained in:
blankie 2023-03-30 22:02:48 +07:00
parent 55210a7e30
commit 2a0bffd8bb
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 5 additions and 1 deletions

View File

@ -60,8 +60,12 @@ const char* to_string_lower(Buffer buffer) {
} }
std::string to_string(const LogcatEntry& logcat_entry) { std::string to_string(const LogcatEntry& logcat_entry) {
struct tm tm = logcat_entry.time;
time_t time = mktime(&tm);
gmtime_r(&time, &tm);
char logcat_style_time_as_str[32] = {0}; char logcat_style_time_as_str[32] = {0};
strftime(logcat_style_time_as_str, 31 * sizeof(char), "%Y-%m-%d %H:%M:%S", &logcat_entry.time); strftime(logcat_style_time_as_str, 31 * sizeof(char), "%Y-%m-%d %H:%M:%S", &tm);
return std::string(logcat_style_time_as_str) return std::string(logcat_style_time_as_str)
+ ' ' + leftpad(logcat_entry.user.value_or(" "), 5) + ' ' + leftpad(logcat_entry.user.value_or(" "), 5)