summaryrefslogtreecommitdiffstats
path: root/src/libnetdata/parsers/timeframe.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-09 08:36:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-25 11:21:20 +0000
commiteae52fdaa9298e00f14b0b6256400d200db9c373 (patch)
treea3040a19bd024295ded05370853647bab9d7c225 /src/libnetdata/parsers/timeframe.h
parentAdding upstream version 1.47.5. (diff)
downloadnetdata-eae52fdaa9298e00f14b0b6256400d200db9c373.tar.xz
netdata-eae52fdaa9298e00f14b0b6256400d200db9c373.zip
Adding upstream version 2.0.3.upstream/2.0.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libnetdata/parsers/timeframe.h')
-rw-r--r--src/libnetdata/parsers/timeframe.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libnetdata/parsers/timeframe.h b/src/libnetdata/parsers/timeframe.h
new file mode 100644
index 000000000..a176dd30a
--- /dev/null
+++ b/src/libnetdata/parsers/timeframe.h
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#ifndef NETDATA_TIMEFRAME_H
+#define NETDATA_TIMEFRAME_H
+
+#include "parsers.h"
+
+typedef struct {
+ time_t after;
+ time_t before;
+} TIMEFRAME;
+
+#define API_RELATIVE_TIME_MAX (3 * 365 * 86400)
+
+#define API_RELATIVE_TIME_INVALID (-1000000000)
+
+#define API_RELATIVE_TIME_THIS_MINUTE (API_RELATIVE_TIME_INVALID - 1) // this minute at 00 seconds
+#define API_RELATIVE_TIME_THIS_HOUR (API_RELATIVE_TIME_INVALID - 2) // this hour at 00 minutes, 00 seconds
+#define API_RELATIVE_TIME_TODAY (API_RELATIVE_TIME_INVALID - 3) // today at 00:00:00
+#define API_RELATIVE_TIME_THIS_WEEK (API_RELATIVE_TIME_INVALID - 4) // this Monday, 00:00:00
+#define API_RELATIVE_TIME_THIS_MONTH (API_RELATIVE_TIME_INVALID - 5) // this month's 1st at 00:00:00
+#define API_RELATIVE_TIME_THIS_YEAR (API_RELATIVE_TIME_INVALID - 6) // this year's Jan 1st, at 00:00:00
+#define API_RELATIVE_TIME_LAST_MONTH (API_RELATIVE_TIME_INVALID - 7) // last month's 1st, at 00:00:00
+#define API_RELATIVE_TIME_LAST_YEAR (API_RELATIVE_TIME_INVALID - 8) // last year's Jan 1st, at 00:00:00
+
+#define TIMEFRAME_INVALID (TIMEFRAME){ .after = API_RELATIVE_TIME_INVALID, .before = API_RELATIVE_TIME_INVALID }
+
+#endif //NETDATA_TIMEFRAME_H