time_fmt.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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-2019, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file time_fmt.h
  8. *
  9. * \brief Header for time_fmt.c
  10. **/
  11. #ifndef TOR_TIME_FMT_H
  12. #define TOR_TIME_FMT_H
  13. #include "orconfig.h"
  14. #ifdef HAVE_SYS_TYPES_H
  15. #include <sys/types.h>
  16. #endif
  17. struct tm;
  18. struct timeval;
  19. struct tm *tor_localtime_r(const time_t *timep, struct tm *result);
  20. struct tm *tor_gmtime_r(const time_t *timep, struct tm *result);
  21. int tor_timegm(const struct tm *tm, time_t *time_out);
  22. #define RFC1123_TIME_LEN 29
  23. void format_rfc1123_time(char *buf, time_t t);
  24. int parse_rfc1123_time(const char *buf, time_t *t);
  25. #define ISO_TIME_LEN 19
  26. #define ISO_TIME_USEC_LEN (ISO_TIME_LEN+7)
  27. void format_local_iso_time(char *buf, time_t t);
  28. void format_iso_time(char *buf, time_t t);
  29. void format_local_iso_time_nospace(char *buf, time_t t);
  30. void format_iso_time_nospace(char *buf, time_t t);
  31. void format_iso_time_nospace_usec(char *buf, const struct timeval *tv);
  32. int parse_iso_time_(const char *cp, time_t *t, int strict, int nospace);
  33. int parse_iso_time(const char *buf, time_t *t);
  34. int parse_iso_time_nospace(const char *cp, time_t *t);
  35. int parse_http_time(const char *buf, struct tm *tm);
  36. int format_time_interval(char *out, size_t out_len, long interval);
  37. #endif