Tor 0.4.9.0-alpha-dev
time_fmt.h
Go to the documentation of this file.
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 */
6
7/**
8 * \file time_fmt.h
9 *
10 * \brief Header for time_fmt.c
11 **/
12
13#ifndef TOR_TIME_FMT_H
14#define TOR_TIME_FMT_H
15
16#include "orconfig.h"
17#ifdef HAVE_SYS_TYPES_H
18#include <sys/types.h>
19#endif
20
22
23struct tm;
24struct timeval;
25
26struct tm *tor_localtime_r(const time_t *timep, struct tm *result);
27struct tm *tor_gmtime_r(const time_t *timep, struct tm *result);
28int tor_timegm(const struct tm *tm, time_t *time_out);
29
30#define RFC1123_TIME_LEN 29
31void format_rfc1123_time(char *buf, time_t t);
32int 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)
35void format_local_iso_time(char *buf, time_t t);
36void format_iso_time(char *buf, time_t t);
37void format_local_iso_time_nospace(char *buf, time_t t);
38void format_iso_time_nospace(char *buf, time_t t);
39void format_iso_time_nospace_usec(char *buf, const struct timeval *tv);
40int parse_iso_time_(const char *cp, time_t *t, int strict, int nospace);
41int parse_iso_time(const char *buf, time_t *t);
42int parse_iso_time_nospace(const char *cp, time_t *t);
43int parse_http_time(const char *buf, struct tm *tm);
44int format_time_interval(char *out, size_t out_len, long interval);
45
46#ifdef TIME_FMT_PRIVATE
47STATIC int tor_timegm_impl(const struct tm *tm, time_t *time_out);
48#endif
49
50#endif /* !defined(TOR_TIME_FMT_H) */
Macros to implement mocking and selective exposure for the test code.
#define STATIC
Definition: testsupport.h:32
ATTR_UNUSED STATIC int tor_timegm_impl(const struct tm *tm, time_t *time_out)
Definition: time_fmt.c:98
int parse_http_time(const char *buf, struct tm *tm)
Definition: time_fmt.c:440
struct tm * tor_gmtime_r(const time_t *timep, struct tm *result)
Definition: time_fmt.c:67
void format_iso_time_nospace(char *buf, time_t t)
Definition: time_fmt.c:344
void format_rfc1123_time(char *buf, time_t t)
Definition: time_fmt.c:213
void format_iso_time_nospace_usec(char *buf, const struct timeval *tv)
Definition: time_fmt.c:354
void format_iso_time(char *buf, time_t t)
Definition: time_fmt.c:326
int parse_iso_time_(const char *cp, time_t *t, int strict, int nospace)
Definition: time_fmt.c:367
void format_local_iso_time_nospace(char *buf, time_t t)
Definition: time_fmt.c:335
int parse_rfc1123_time(const char *buf, time_t *t)
Definition: time_fmt.c:237
void format_local_iso_time(char *buf, time_t t)
Definition: time_fmt.c:316
int parse_iso_time(const char *buf, time_t *t)
Definition: time_fmt.c:423
int tor_timegm(const struct tm *tm, time_t *time_out)
Definition: time_fmt.c:171
int format_time_interval(char *out, size_t out_len, long interval)
Definition: time_fmt.c:512
int parse_iso_time_nospace(const char *cp, time_t *t)
Definition: time_fmt.c:432
struct tm * tor_localtime_r(const time_t *timep, struct tm *result)
Definition: time_fmt.c:48