summaryrefslogtreecommitdiffstats
path: root/include/osmocom/core
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-09-25 16:37:37 +0200
committerMax <msuraev@sysmocom.de>2017-09-25 14:41:41 +0000
commit383c5635e3920091469594ee01c2b9b13b6ea408 (patch)
tree2b153a6c7dd2399933b1022f3ffdcf0c86fbda45 /include/osmocom/core
parent657c5b6cadcef470c7ff9bffed3caab227026e6a (diff)
Add time conversion helpers
Add macros to break down absolute time in seconds into days/hours/minutes passed. Change-Id: I46b9a405c18ed9da8f31b7d5b6dcece5468bafbf
Diffstat (limited to 'include/osmocom/core')
-rw-r--r--include/osmocom/core/timer.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/osmocom/core/timer.h b/include/osmocom/core/timer.h
index 40b39b90..4958efb3 100644
--- a/include/osmocom/core/timer.h
+++ b/include/osmocom/core/timer.h
@@ -45,6 +45,11 @@
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/linuxrbtree.h>
+/* convert absolute time (in seconds) to elapsed days/hours/minutes */
+#define OSMO_SEC2MIN(sec) ((sec % (60 * 60)) / 60)
+#define OSMO_SEC2HRS(sec) ((sec % (60 * 60 * 24)) / (60 * 60))
+#define OSMO_SEC2DAY(sec) ((sec % (60 * 60 * 24 * 365)) / (60 * 60 * 24)) /* we ignore leap year for simplicity */
+
/*! A structure representing a single instance of a timer */
struct osmo_timer_list {
struct rb_node node; /*!< rb-tree node header */