1 /* Copyright (c) 2001, Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
10 * \brief Header for time_fmt.c
13 #ifndef TOR_TIME_FMT_H
14 #define TOR_TIME_FMT_H
17 #ifdef HAVE_SYS_TYPES_H
18 #include <sys/types.h>
21 #include "lib/testsupport/testsupport.h"
26 struct tm
*tor_localtime_r(const time_t *timep
, struct tm
*result
);
27 struct tm
*tor_gmtime_r(const time_t *timep
, struct tm
*result
);
28 int tor_timegm(const struct tm
*tm
, time_t *time_out
);
30 #define RFC1123_TIME_LEN 29
31 void format_rfc1123_time(char *buf
, time_t t
);
32 int parse_rfc1123_time(const char *buf
, time_t *t
);
33 #define ISO_TIME_LEN 19
34 #define ISO_TIME_USEC_LEN (ISO_TIME_LEN+7)
35 void format_local_iso_time(char *buf
, time_t t
);
36 void format_iso_time(char *buf
, time_t t
);
37 void format_local_iso_time_nospace(char *buf
, time_t t
);
38 void format_iso_time_nospace(char *buf
, time_t t
);
39 void format_iso_time_nospace_usec(char *buf
, const struct timeval
*tv
);
40 int parse_iso_time_(const char *cp
, time_t *t
, int strict
, int nospace
);
41 int parse_iso_time(const char *buf
, time_t *t
);
42 int parse_iso_time_nospace(const char *cp
, time_t *t
);
43 int parse_http_time(const char *buf
, struct tm
*tm
);
44 int format_time_interval(char *out
, size_t out_len
, long interval
);
46 #ifdef TIME_FMT_PRIVATE
47 STATIC
int tor_timegm_impl(const struct tm
*tm
, time_t *time_out
);
50 #endif /* !defined(TOR_TIME_FMT_H) */