]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/monotime.h
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / lib / monotime.h
index 7bd338649830901ebb713592174f5ef9adf5d06e..00b9400462e2f6c8b6e49c29ae6e1099fd80854c 100644 (file)
@@ -49,6 +49,10 @@ static inline time_t monotime(struct timeval *tvo)
        return ts.tv_sec;
 }
 
+#define ONE_DAY_SECOND 60*60*24
+#define ONE_WEEK_SECOND ONE_DAY_SECOND*7
+#define ONE_YEAR_SECOND ONE_DAY_SECOND*365
+
 /* the following two return microseconds, not time_t!
  *
  * also, they're negative forms of each other, but having both makes the
@@ -76,4 +80,15 @@ static inline int64_t monotime_until(const struct timeval *ref,
        return (int64_t)tv.tv_sec * 1000000LL + tv.tv_usec;
 }
 
+static inline char *time_to_string(time_t ts)
+{
+       struct timeval tv;
+       time_t tbuf;
+
+       monotime(&tv);
+       tbuf = time(NULL) - (tv.tv_sec - ts);
+
+       return ctime(&tbuf);
+}
+
 #endif /* _FRR_MONOTIME_H */