[PATCH] libosmocore[master]: Add time conversion helpers

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Mon Sep 25 14:38:45 UTC 2017


Review at  https://gerrit.osmocom.org/4060

Add time conversion helpers

Add macros to break down absolute time in seconds into days/hors/minutes
passed.

Change-Id: I46b9a405c18ed9da8f31b7d5b6dcece5468bafbf
---
M include/osmocom/core/timer.h
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/60/4060/1

diff --git a/include/osmocom/core/timer.h b/include/osmocom/core/timer.h
index 40b39b9..4958efb 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 */

-- 
To view, visit https://gerrit.osmocom.org/4060
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I46b9a405c18ed9da8f31b7d5b6dcece5468bafbf
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list