diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-06-27 16:17:46 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-06-27 16:59:56 -0400 |
commit | 194a34cdc28c6b309dd9a32f5446409810b1d32b (patch) | |
tree | 6828a25a54dc81331bc1fead946a0c1ade2fede4 /src/lib/encoding/time_fmt.h | |
parent | 235ddb15a0f9fc322002ba39e8900634316dc333 (diff) | |
download | tor-194a34cdc28c6b309dd9a32f5446409810b1d32b.tar.gz tor-194a34cdc28c6b309dd9a32f5446409810b1d32b.zip |
Extract time encoding functions into lib/encoding
Diffstat (limited to 'src/lib/encoding/time_fmt.h')
-rw-r--r-- | src/lib/encoding/time_fmt.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/lib/encoding/time_fmt.h b/src/lib/encoding/time_fmt.h new file mode 100644 index 0000000000..41508ce5e6 --- /dev/null +++ b/src/lib/encoding/time_fmt.h @@ -0,0 +1,38 @@ +/* Copyright (c) 2001, Matej Pfajfar. + * Copyright (c) 2001-2004, Roger Dingledine. + * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. + * Copyright (c) 2007-2018, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +#ifndef TOR_TIME_FMT_H +#define TOR_TIME_FMT_H + +#include "orconfig.h" +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif + +struct tm; +struct timeval; + +struct tm *tor_localtime_r(const time_t *timep, struct tm *result); +struct tm *tor_gmtime_r(const time_t *timep, struct tm *result); +int tor_timegm(const struct tm *tm, time_t *time_out); + +#define RFC1123_TIME_LEN 29 +void format_rfc1123_time(char *buf, time_t t); +int parse_rfc1123_time(const char *buf, time_t *t); +#define ISO_TIME_LEN 19 +#define ISO_TIME_USEC_LEN (ISO_TIME_LEN+7) +void format_local_iso_time(char *buf, time_t t); +void format_iso_time(char *buf, time_t t); +void format_local_iso_time_nospace(char *buf, time_t t); +void format_iso_time_nospace(char *buf, time_t t); +void format_iso_time_nospace_usec(char *buf, const struct timeval *tv); +int parse_iso_time_(const char *cp, time_t *t, int strict, int nospace); +int parse_iso_time(const char *buf, time_t *t); +int parse_iso_time_nospace(const char *cp, time_t *t); +int parse_http_time(const char *buf, struct tm *tm); +int format_time_interval(char *out, size_t out_len, long interval); + +#endif |