httpdate.h 506 B

123456789101112131415161718192021
  1. #pragma once
  2. #include <util/datetime/base.h>
  3. #include <util/generic/string.h>
  4. #include <ctime>
  5. #define BAD_DATE ((time_t)-1)
  6. inline time_t parse_http_date(const TStringBuf& datestring) {
  7. try {
  8. return TInstant::ParseHttpDeprecated(datestring).TimeT();
  9. } catch (const TDateTimeParseException&) {
  10. return BAD_DATE;
  11. }
  12. }
  13. int format_http_date(char buf[], size_t size, time_t when);
  14. char* format_http_date(time_t when, char* buf, size_t len);
  15. TString FormatHttpDate(time_t when);