diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-05-17 17:01:25 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-05-17 17:01:25 +0200 |
commit | b1401f93da11d38d49a5117d4f717fec384e7176 (patch) | |
tree | 39d197e4ce5b92ce843dec69caacb8ab8aaea5e6 /src/util/json.c | |
parent | 3817f83dd5b65fb7d475560b2637276a89f69087 (diff) |
test json-time conversion, add support for forever/never time
Diffstat (limited to 'src/util/json.c')
-rw-r--r-- | src/util/json.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util/json.c b/src/util/json.c index 90031faae..8abcef1c9 100644 --- a/src/util/json.c +++ b/src/util/json.c @@ -83,6 +83,9 @@ TALER_json_from_abs (struct GNUNET_TIME_Absolute stamp) json_t *j; char *mystr; int ret; + + if (stamp.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) + return json_string ("never"); ret = GNUNET_asprintf (&mystr, "%llu", (long long) (stamp.abs_value_us / (1000 * 1000))); @@ -259,6 +262,12 @@ TALER_json_to_abs (json_t *json, GNUNET_assert (NULL != abs); EXITIF (NULL == (str = json_string_value (json))); + if (0 == strcasecmp (str, + "never")) + { + *abs = GNUNET_TIME_UNIT_FOREVER_ABS; + return GNUNET_OK; + } EXITIF (1 > sscanf (str, "%llu", &abs_value_s)); abs->abs_value_us = abs_value_s * 1000 * 1000; return GNUNET_OK; |