aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2022-03-21 03:37:29 +0100
committerChristian Grothoff <grothoff@gnunet.org>2022-03-21 03:38:18 +0100
commitec8a825b0e56c692c4879db10c6b25cd26bb42e4 (patch)
treea08ab989b42aa01933410b8bf54ddfb8243151f7 /src/util
parente96a9eb00942666fceb2a3658ee7b6d2784a098c (diff)
downloadgnunet-ec8a825b0e56c692c4879db10c6b25cd26bb42e4.tar.gz
gnunet-ec8a825b0e56c692c4879db10c6b25cd26bb42e4.zip
add new approximate time cmp function
Diffstat (limited to 'src/util')
-rw-r--r--src/util/time.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util/time.c b/src/util/time.c
index 68a6937a0..aeec2b3f9 100644
--- a/src/util/time.c
+++ b/src/util/time.c
@@ -58,6 +58,22 @@ GNUNET_TIME_get_offset ()
58} 58}
59 59
60 60
61bool
62GNUNET_TIME_absolute_approx_eq (struct GNUNET_TIME_Absolute a1,
63 struct GNUNET_TIME_Absolute a2,
64 struct GNUNET_TIME_Relative t)
65{
66 struct GNUNET_TIME_Relative delta;
67
68 delta = GNUNET_TIME_relative_min (
69 GNUNET_TIME_absolute_get_difference (a1, a2),
70 GNUNET_TIME_absolute_get_difference (a2, a1));
71 return GNUNET_TIME_relative_cmp (delta,
72 <=,
73 t);
74}
75
76
61struct GNUNET_TIME_Timestamp 77struct GNUNET_TIME_Timestamp
62GNUNET_TIME_absolute_to_timestamp (struct GNUNET_TIME_Absolute at) 78GNUNET_TIME_absolute_to_timestamp (struct GNUNET_TIME_Absolute at)
63{ 79{