Use local hh:mm:ss in SD CSV human-readable column
This commit is contained in:
@@ -39,18 +39,18 @@ static String format_date_utc(uint32_t ts_utc) {
|
||||
return String(buf);
|
||||
}
|
||||
|
||||
static String format_hms_utc(uint32_t ts_utc) {
|
||||
static String format_hms_local(uint32_t ts_utc) {
|
||||
if (ts_utc == 0) {
|
||||
return "";
|
||||
}
|
||||
time_t t = static_cast<time_t>(ts_utc);
|
||||
struct tm tm_utc;
|
||||
gmtime_r(&t, &tm_utc);
|
||||
struct tm tm_local;
|
||||
localtime_r(&t, &tm_local);
|
||||
char buf[16];
|
||||
snprintf(buf, sizeof(buf), "%02d:%02d:%02d",
|
||||
tm_utc.tm_hour,
|
||||
tm_utc.tm_min,
|
||||
tm_utc.tm_sec);
|
||||
tm_local.tm_hour,
|
||||
tm_local.tm_min,
|
||||
tm_local.tm_sec);
|
||||
return String(buf);
|
||||
}
|
||||
|
||||
@@ -102,13 +102,13 @@ void sd_logger_log_sample(const MeterData &data, bool include_error_text) {
|
||||
}
|
||||
|
||||
if (new_file) {
|
||||
f.println("ts_utc,ts_hms_utc,p_w,p1_w,p2_w,p3_w,e_kwh,bat_v,bat_pct,rssi,snr,err_m,err_d,err_tx,err_last");
|
||||
f.println("ts_utc,ts_hms_local,p_w,p1_w,p2_w,p3_w,e_kwh,bat_v,bat_pct,rssi,snr,err_m,err_d,err_tx,err_last");
|
||||
}
|
||||
|
||||
String ts_hms_utc = format_hms_utc(data.ts_utc);
|
||||
String ts_hms_local = format_hms_local(data.ts_utc);
|
||||
f.print(data.ts_utc);
|
||||
f.print(',');
|
||||
f.print(ts_hms_utc);
|
||||
f.print(ts_hms_local);
|
||||
f.print(',');
|
||||
f.print(data.total_power_w, 1);
|
||||
f.print(',');
|
||||
|
||||
Reference in New Issue
Block a user