From 3f9e16f03804b2a09570775054b86e3f8cd2973a Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 1 Oct 2025 23:21:50 +0200 Subject: [PATCH] aqhome-tool: allow for data spec for timestamps (YYYY/MM/DD-HH:MM:SS) --- apps/aqhome-tool/utils.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/apps/aqhome-tool/utils.c b/apps/aqhome-tool/utils.c index 5c7ddf1..8d8b23b 100644 --- a/apps/aqhome-tool/utils.c +++ b/apps/aqhome-tool/utils.c @@ -384,11 +384,31 @@ uint64_t Utils_GetTimeStampFromString(const char *s) case 'm': x*=60; break; case 'h': x*=(60*60); break; case 'd': x*=(60*60*24); break; + case 'w': x*=(60*60*24*7); break; + case 'M': x*=(60*60*24*30); break; + case 'y': x*=(60*60*24*365); break; default: break; } } return (now-x); } + if (*s=='@') { + int y, m, d, H, M, S; + + if (6==sscanf(s+1, "%d/%d/%d-%d:%d:%d", &y, &m, &d, &H, &M, &S)) { + GWEN_TIMESTAMP *ts; + uint64_t x=0; + + ts=GWEN_Timestamp_new(y, m, d, H, M, S); + x=GWEN_Timestamp_toTimeT(ts); + GWEN_Timestamp_free(ts); + return x; + } + else { + DBG_ERROR(NULL, "Invalid timespec [%s], expected: @YYYY/MM/DD-HH:MM:SS", s); + return (uint64_t) (-1); + } + } else { unsigned long int x;