diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-07-05 16:55:01 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-07-05 16:55:01 +0200 |
commit | 922323b4104abfaef2a11fed4e5e8292344a3bcd (patch) | |
tree | 8ed3781141741e743d120180b7e785f6a38eca3c /src/util/util.c | |
parent | f623214c1292b93fa8672361dfa978a506f4bef3 (diff) | |
download | exchange-922323b4104abfaef2a11fed4e5e8292344a3bcd.tar.xz |
misc bugfixes from tests
Diffstat (limited to 'src/util/util.c')
-rw-r--r-- | src/util/util.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/util/util.c b/src/util/util.c index 6da2f3f78..1d8b09c4d 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -64,6 +64,46 @@ TALER_config_get_denom (struct GNUNET_CONFIGURATION_Handle *cfg, /** + * Round a time value so that it is suitable for transmission + * via JSON encodings. + * + * @param at time to round + * @return #GNUNET_OK if time was already rounded, #GNUNET_NO if + * it was just now rounded + */ +int +TALER_round_abs_time (struct GNUNET_TIME_Absolute *at) +{ + if (at->abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) + return GNUNET_OK; + if (0 == at->abs_value_us % 1000000) + return GNUNET_OK; + at->abs_value_us -= at->abs_value_us % 1000000; + return GNUNET_NO; +} + + +/** + * Round a time value so that it is suitable for transmission + * via JSON encodings. + * + * @param rt time to round + * @return #GNUNET_OK if time was already rounded, #GNUNET_NO if + * it was just now rounded + */ +int +TALER_round_rel_time (struct GNUNET_TIME_Relative *rt) +{ + if (rt->rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) + return GNUNET_OK; + if (0 == rt->rel_value_us % 1000000) + return GNUNET_OK; + rt->rel_value_us -= rt->rel_value_us % 1000000; + return GNUNET_NO; +} + + +/** * Load configuration by parsing all configuration * files in the given directory. * |