From f44e475c12f992392e7a7d9f4fd6c09f1b0bf9a9 Mon Sep 17 00:00:00 2001 From: noori Date: Tue, 16 May 2023 21:34:09 +0330 Subject: [PATCH] modified the timestamp function and added a new function to Calculate first part of TDMS Timestamp --- TDMS.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/TDMS.c b/TDMS.c index a4bf5d9..a409090 100644 --- a/TDMS.c +++ b/TDMS.c @@ -1041,6 +1041,7 @@ TDMS_SetGroupDataValues(TDMS_Group_t *Group, * @param Second: Normal Second (0 to 59) * @retval Second part of TDMS Timestamp */ + //The most significant 64 bits of timestamp int64_t TDMS_TimeSecond(uint16_t Year, uint8_t Month, uint8_t Day, uint8_t Hour, uint8_t Minute, uint8_t Second) @@ -1049,10 +1050,27 @@ TDMS_TimeSecond(uint16_t Year, uint8_t Month, uint8_t Day, int64_t DiffSecond; DiffDay = TDMS_DateDef(Day, Month, Year); - DiffSecond = (int64_t) (DiffDay * 86400ul); - DiffSecond += (int64_t) (Hour * 3600); - DiffSecond += (int64_t) (Minute * 60); + DiffSecond = ((int64_t)DiffDay * 86400ul); + DiffSecond += ((int64_t)Hour * 3600); + DiffSecond += ((int64_t)Minute * 60); DiffSecond += (int64_t) (Second); return DiffSecond; } + + + +// when input = 500ms then output should be = 9223372036854775808 +// so this function should multiply input MS in 18446744073709552 factor +#define factor 18446744073709552 +/** + @brief Calculate first part of TDMS Timestamp from milliseconds input + @param ms: milliSecond + @retval first part of TDMS Timestamp +*/ + //The least significant 64 bits of timestamp +int64_t +TDMS_TimeMilliSecond(uint64_t ms) +{ + return factor*(ms%1000); +} \ No newline at end of file