aboutsummaryrefslogtreecommitdiff
path: root/src/util/strings.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-12-14 15:59:07 +0100
committerChristian Grothoff <christian@grothoff.org>2021-12-14 15:59:12 +0100
commit99779b455ce3bf9c53dd411575766bf298a3a5f3 (patch)
tree12cd49f097fdd1947580b08ec10ca961f8c250b9 /src/util/strings.c
parent8c702327dae9e504e0f6e1678884d9327321f44a (diff)
downloadgnunet-99779b455ce3bf9c53dd411575766bf298a3a5f3.tar.gz
gnunet-99779b455ce3bf9c53dd411575766bf298a3a5f3.zip
introducing GNUNET_TIME_Timestamp
Diffstat (limited to 'src/util/strings.c')
-rw-r--r--src/util/strings.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/util/strings.c b/src/util/strings.c
index 673915888..db672da87 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -201,7 +201,7 @@ struct ConversionTable
201 * @param output where to store the result 201 * @param output where to store the result
202 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 202 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
203 */ 203 */
204static int 204static enum GNUNET_GenericReturnValue
205convert_with_table (const char *input, 205convert_with_table (const char *input,
206 const struct ConversionTable *table, 206 const struct ConversionTable *table,
207 unsigned long long *output) 207 unsigned long long *output)
@@ -256,7 +256,7 @@ convert_with_table (const char *input,
256} 256}
257 257
258 258
259int 259enum GNUNET_GenericReturnValue
260GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size, 260GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size,
261 unsigned long long *size) 261 unsigned long long *size)
262{ 262{
@@ -280,7 +280,7 @@ GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size,
280} 280}
281 281
282 282
283int 283enum GNUNET_GenericReturnValue
284GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time, 284GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time,
285 struct GNUNET_TIME_Relative *rtime) 285 struct GNUNET_TIME_Relative *rtime)
286{ 286{
@@ -322,7 +322,7 @@ GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time,
322} 322}
323 323
324 324
325int 325enum GNUNET_GenericReturnValue
326GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, 326GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time,
327 struct GNUNET_TIME_Absolute *atime) 327 struct GNUNET_TIME_Absolute *atime)
328{ 328{
@@ -354,6 +354,15 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time,
354} 354}
355 355
356 356
357enum GNUNET_GenericReturnValue
358GNUNET_STRINGS_fancy_time_to_timestamp (const char *fancy_time,
359 struct GNUNET_TIME_Timestamp *atime)
360{
361 return GNUNET_STRINGS_fancy_time_to_absolute (fancy_time,
362 &atime->abs_time);
363}
364
365
357char * 366char *
358GNUNET_STRINGS_conv (const char *input, 367GNUNET_STRINGS_conv (const char *input,
359 size_t len, 368 size_t len,
@@ -607,7 +616,7 @@ GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t)
607 time_t tt; 616 time_t tt;
608 struct tm *tp; 617 struct tm *tp;
609 618
610 if (t.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) 619 if (GNUNET_TIME_absolute_is_never (t))
611 return "end of time"; 620 return "end of time";
612 tt = t.abs_value_us / 1000LL / 1000LL; 621 tt = t.abs_value_us / 1000LL / 1000LL;
613 tp = localtime (&tt); 622 tp = localtime (&tt);
@@ -616,7 +625,8 @@ GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t)
616 * As for msvcrt, use the wide variant, which always returns utf16 625 * As for msvcrt, use the wide variant, which always returns utf16
617 * (otherwise we'd have to detect current codepage or use W32API character 626 * (otherwise we'd have to detect current codepage or use W32API character
618 * set conversion routines to convert to UTF8). 627 * set conversion routines to convert to UTF8).
619 */strftime (buf, sizeof(buf), "%a %b %d %H:%M:%S %Y", tp); 628 */
629 strftime (buf, sizeof(buf), "%a %b %d %H:%M:%S %Y", tp);
620 630
621 return buf; 631 return buf;
622} 632}