diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-03 20:39:50 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-03 20:39:50 +0000 |
commit | e098493e473fcdc4824e9ab05518ffe1460af1e6 (patch) | |
tree | 1a75dfa9b94854dc246c0cd53f3c573912f635ba /src/util/time.c | |
parent | 03061fed4e303d20e3027d1864e04578b2ea4cfd (diff) | |
download | gnunet-e098493e473fcdc4824e9ab05518ffe1460af1e6.tar.gz gnunet-e098493e473fcdc4824e9ab05518ffe1460af1e6.zip |
time subtract
Diffstat (limited to 'src/util/time.c')
-rw-r--r-- | src/util/time.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/util/time.c b/src/util/time.c index 6eccf4d9a..3d53e0af2 100644 --- a/src/util/time.c +++ b/src/util/time.c | |||
@@ -270,6 +270,33 @@ GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start, | |||
270 | return ret; | 270 | return ret; |
271 | } | 271 | } |
272 | 272 | ||
273 | |||
274 | /** | ||
275 | * Subtract a given relative duration from the | ||
276 | * given start time. | ||
277 | * | ||
278 | * @param start some absolute time | ||
279 | * @param duration some relative time to subtract | ||
280 | * @return ZERO if start <= duration, or FOREVER if start time is FOREVER; start-duration otherwise | ||
281 | */ | ||
282 | struct GNUNET_TIME_Absolute | ||
283 | GNUNET_TIME_absolute_subtract (struct | ||
284 | GNUNET_TIME_Absolute | ||
285 | start, | ||
286 | struct | ||
287 | GNUNET_TIME_Relative | ||
288 | duration) | ||
289 | { | ||
290 | struct GNUNET_TIME_Absolute ret; | ||
291 | if (start.value <= duration.value) | ||
292 | return GNUNET_TIME_UNIT_ZERO_ABS; | ||
293 | if (start.value == GNUNET_TIME_UNIT_FOREVER_ABS.value) | ||
294 | return GNUNET_TIME_UNIT_FOREVER_ABS; | ||
295 | ret.value = start.value - duration.value; | ||
296 | return ret; | ||
297 | } | ||
298 | |||
299 | |||
273 | /** | 300 | /** |
274 | * Multiply relative time by a given factor. | 301 | * Multiply relative time by a given factor. |
275 | * | 302 | * |