diff options
Diffstat (limited to 'src/util/time.c')
-rw-r--r-- | src/util/time.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/util/time.c b/src/util/time.c index 68a6937a0..cf072aebf 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 | { |
@@ -370,6 +386,20 @@ GNUNET_TIME_timestamp_min (struct GNUNET_TIME_Timestamp t1, | |||
370 | } | 386 | } |
371 | 387 | ||
372 | 388 | ||
389 | struct GNUNET_TIME_Absolute | ||
390 | GNUNET_TIME_absolute_round_down (struct GNUNET_TIME_Absolute at, | ||
391 | struct GNUNET_TIME_Relative rt) | ||
392 | { | ||
393 | struct GNUNET_TIME_Absolute ret; | ||
394 | |||
395 | GNUNET_assert (! GNUNET_TIME_relative_is_zero (rt)); | ||
396 | ret.abs_value_us | ||
397 | = at.abs_value_us | ||
398 | - at.abs_value_us % rt.rel_value_us; | ||
399 | return ret; | ||
400 | } | ||
401 | |||
402 | |||
373 | struct GNUNET_TIME_Relative | 403 | struct GNUNET_TIME_Relative |
374 | GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future) | 404 | GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future) |
375 | { | 405 | { |