time_fmt.h 1.3 KB

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