From 383c5635e3920091469594ee01c2b9b13b6ea408 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 25 Sep 2017 16:37:37 +0200 Subject: Add time conversion helpers Add macros to break down absolute time in seconds into days/hours/minutes passed. Change-Id: I46b9a405c18ed9da8f31b7d5b6dcece5468bafbf --- include/osmocom/core/timer.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') 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 #include +/* 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 */ -- cgit v1.2.3