From 1c4e2dcafc7b2e493a93fbd00ddf4d6cd2f3d389 Mon Sep 17 00:00:00 2001 From: Jerzy Jamroz Date: Thu, 23 Nov 2023 16:26:04 +0100 Subject: [PATCH] fix: Normalize the Time-I record timestamp to 1s. Time-I displays the time without the ms part which means it has to be rounded accordingly. --- evrApp/src/devEvrStringIO.cpp | 10 +++++++++- mrfCommon/src/mrfCommon.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/evrApp/src/devEvrStringIO.cpp b/evrApp/src/devEvrStringIO.cpp index 617b57f6..a3e2b2f4 100644 --- a/evrApp/src/devEvrStringIO.cpp +++ b/evrApp/src/devEvrStringIO.cpp @@ -101,10 +101,18 @@ try { if (ts.secPastEpoch==priv->last_bad) return 0; + // Normalize the timestamp to seconds + epicsTimeStamp ts_sec = ts; + // Round the timestamp to 1s accuracy + if (ts_sec.nsec + 500000000u >= 1000000000u) + ts_sec.secPastEpoch += 1; + + ts_sec.nsec = 0; // Remove the ns part + size_t r=epicsTimeToStrftime(prec->val, sizeof(prec->val), "%a, %d %b %Y %H:%M:%S %z", - &ts); + &ts_sec); if(r==0||r==sizeof(prec->val)){ recGblRecordError(S_dev_badArgument, (void*)prec, "Format string resulted in error"); diff --git a/mrfCommon/src/mrfCommon.h b/mrfCommon/src/mrfCommon.h index a8bd8062..3e4b94d5 100644 --- a/mrfCommon/src/mrfCommon.h +++ b/mrfCommon/src/mrfCommon.h @@ -252,7 +252,7 @@ struct SB { * * To quote the manual: * Subrelease ID For production releases the subrelease ID counts up from 00. - * For pre-releases this ID is used “backwards” counting down from ff i.e. when + * For pre-releases this ID is used "backwards" counting down from ff i.e. when * approacing release 12000207, we have prereleases 12FF0206, 12FE0206, * 12FD0206 etc. in this order. */