From 5b83cad8fbb0c38d1cef526410d95584c5a9e538 Mon Sep 17 00:00:00 2001 From: Robert Johansson Date: Thu, 4 Jul 2013 23:47:06 +0900 Subject: [PATCH] only show timestamp in XML output if it is set (not all frames that goes into mbus_parse passes through timestamp), to avoid a lot of '1970-01-01T00:00:00' --- mbus/mbus-protocol.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 6ecb015..cec73bb 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -3587,10 +3587,14 @@ mbus_data_variable_record_xml(mbus_data_record *record, int record_cnt, int fram mbus_str_xml_encode(str_encoded, mbus_data_record_value(record), sizeof(str_encoded)); len += snprintf(&buff[len], sizeof(buff) - len, " %s\n", str_encoded); - - timeinfo = gmtime ( &(record->timestamp) ); - strftime(timestamp,20,"%Y-%m-%dT%H:%M:%S",timeinfo); - len += snprintf(&buff[len], sizeof(buff) - len, " %s\n", timestamp); + + if (record->timestamp > 0) + { + timeinfo = gmtime (&(record->timestamp)); + strftime(timestamp,20,"%Y-%m-%dT%H:%M:%S",timeinfo); + len += snprintf(&buff[len], sizeof(buff) - len, + " %s\n", timestamp); + } len += snprintf(&buff[len], sizeof(buff) - len, " \n\n");