aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-07-23 20:18:47 +0200
committerChristian Grothoff <christian@grothoff.org>2021-07-23 20:18:47 +0200
commit577b336638cc9616edf87cf204a853ffc4e3ab0e (patch)
tree99bcdc0bdbf2b4dbe46b6e419bc1e99a06c4eafa
parentbe8bca81797f31db878a1ecc33659fe931b5b7c0 (diff)
downloadgnunet-577b336638cc9616edf87cf204a853ffc4e3ab0e.tar.gz
gnunet-577b336638cc9616edf87cf204a853ffc4e3ab0e.zip
-even more time functions
-rw-r--r--src/include/gnunet_time_lib.h18
-rw-r--r--src/util/time.c20
2 files changed, 38 insertions, 0 deletions
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h
index ff602194c..26b442066 100644
--- a/src/include/gnunet_time_lib.h
+++ b/src/include/gnunet_time_lib.h
@@ -549,6 +549,24 @@ GNUNET_TIME_absolute_is_never (struct GNUNET_TIME_Absolute abs);
549 549
550 550
551/** 551/**
552 * Test if @a abs is truly in the past (excluding now).
553 *
554 * @return true if it is.
555 */
556bool
557GNUNET_TIME_absolute_is_past (struct GNUNET_TIME_Absolute abs);
558
559
560/**
561 * Test if @a abs is truly in the future (excluding now).
562 *
563 * @return true if it is.
564 */
565bool
566GNUNET_TIME_absolute_is_future (struct GNUNET_TIME_Absolute abs);
567
568
569/**
552 * Test if @a rel is forever. 570 * Test if @a rel is forever.
553 * 571 *
554 * @return true if it is. 572 * @return true if it is.
diff --git a/src/util/time.c b/src/util/time.c
index 3ea5a1ea1..eb7bd6766 100644
--- a/src/util/time.c
+++ b/src/util/time.c
@@ -491,6 +491,26 @@ GNUNET_TIME_relative_is_zero (struct GNUNET_TIME_Relative rel)
491} 491}
492 492
493 493
494bool
495GNUNET_TIME_absolute_is_past (struct GNUNET_TIME_Absolute abs)
496{
497 struct GNUNET_TIME_Absolute now;
498
499 now = GNUNET_TIME_absolute_get ();
500 return abs.abs_value_us < now.abs_value_us;
501}
502
503
504bool
505GNUNET_TIME_absolute_is_future (struct GNUNET_TIME_Absolute abs)
506{
507 struct GNUNET_TIME_Absolute now;
508
509 now = GNUNET_TIME_absolute_get ();
510 return abs.abs_value_us > now.abs_value_us;
511}
512
513
494struct GNUNET_TIME_Absolute 514struct GNUNET_TIME_Absolute
495GNUNET_TIME_absolute_from_ms (uint64_t ms_after_epoch) 515GNUNET_TIME_absolute_from_ms (uint64_t ms_after_epoch)
496{ 516{