diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-07-23 20:10:45 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-07-23 20:10:45 +0200 |
commit | be8bca81797f31db878a1ecc33659fe931b5b7c0 (patch) | |
tree | d01c5f627d04f1f9bd8827921c6cbb8dfbb070fb | |
parent | d44f867e71e13be3970e8803e0ae238e8d3ed7ee (diff) | |
download | gnunet-be8bca81797f31db878a1ecc33659fe931b5b7c0.tar.gz gnunet-be8bca81797f31db878a1ecc33659fe931b5b7c0.zip |
introduce new TIME helper functions
-rw-r--r-- | src/include/gnunet_time_lib.h | 9 | ||||
-rw-r--r-- | src/util/time.c | 7 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h index bddf5c6bf..ff602194c 100644 --- a/src/include/gnunet_time_lib.h +++ b/src/include/gnunet_time_lib.h | |||
@@ -558,6 +558,15 @@ GNUNET_TIME_relative_is_forever (struct GNUNET_TIME_Relative rel); | |||
558 | 558 | ||
559 | 559 | ||
560 | /** | 560 | /** |
561 | * Test if @a rel is zero. | ||
562 | * | ||
563 | * @return true if it is. | ||
564 | */ | ||
565 | bool | ||
566 | GNUNET_TIME_relative_is_zero (struct GNUNET_TIME_Relative rel); | ||
567 | |||
568 | |||
569 | /** | ||
561 | * Convert seconds after the UNIX epoch to absolute time. | 570 | * Convert seconds after the UNIX epoch to absolute time. |
562 | * | 571 | * |
563 | * @param s_after_epoch seconds after epoch to convert | 572 | * @param s_after_epoch seconds after epoch to convert |
diff --git a/src/util/time.c b/src/util/time.c index 15a4160e2..3ea5a1ea1 100644 --- a/src/util/time.c +++ b/src/util/time.c | |||
@@ -484,6 +484,13 @@ GNUNET_TIME_relative_is_forever (struct GNUNET_TIME_Relative rel) | |||
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | bool | ||
488 | GNUNET_TIME_relative_is_zero (struct GNUNET_TIME_Relative rel) | ||
489 | { | ||
490 | return rel.rel_value_us == 0; | ||
491 | } | ||
492 | |||
493 | |||
487 | struct GNUNET_TIME_Absolute | 494 | struct GNUNET_TIME_Absolute |
488 | GNUNET_TIME_absolute_from_ms (uint64_t ms_after_epoch) | 495 | GNUNET_TIME_absolute_from_ms (uint64_t ms_after_epoch) |
489 | { | 496 | { |