diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2022-03-21 03:37:29 +0100 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2022-03-21 03:38:18 +0100 |
commit | ec8a825b0e56c692c4879db10c6b25cd26bb42e4 (patch) | |
tree | a08ab989b42aa01933410b8bf54ddfb8243151f7 /src/util | |
parent | e96a9eb00942666fceb2a3658ee7b6d2784a098c (diff) | |
download | gnunet-ec8a825b0e56c692c4879db10c6b25cd26bb42e4.tar.gz gnunet-ec8a825b0e56c692c4879db10c6b25cd26bb42e4.zip |
add new approximate time cmp function
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/time.c | 16 |
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 | ||
61 | bool | ||
62 | GNUNET_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 | |||
61 | struct GNUNET_TIME_Timestamp | 77 | struct GNUNET_TIME_Timestamp |
62 | GNUNET_TIME_absolute_to_timestamp (struct GNUNET_TIME_Absolute at) | 78 | GNUNET_TIME_absolute_to_timestamp (struct GNUNET_TIME_Absolute at) |
63 | { | 79 | { |