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 '<Timestamp>1970-01-01T00:00:00</Timestamp>'

This commit is contained in:
Robert Johansson 2013-07-04 23:47:06 +09:00
parent 1fee3d9a5a
commit 5b83cad8fb

View File

@ -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, " <Value>%s</Value>\n", str_encoded);
timeinfo = gmtime ( &(record->timestamp) );
strftime(timestamp,20,"%Y-%m-%dT%H:%M:%S",timeinfo);
len += snprintf(&buff[len], sizeof(buff) - len, " <Timestamp>%s</Timestamp>\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,
" <Timestamp>%s</Timestamp>\n", timestamp);
}
len += snprintf(&buff[len], sizeof(buff) - len, " </DataRecord>\n\n");