aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http/misc/httpdate.h
blob: 20915151bf1c02be2f6fe7a01727a3def858d8b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma once

#include <util/datetime/base.h>
#include <util/generic/string.h>

#include <ctime>

#define BAD_DATE ((time_t)-1)

inline time_t parse_http_date(const TStringBuf& datestring) {
    try {
        return TInstant::ParseHttpDeprecated(datestring).TimeT();
    } catch (const TDateTimeParseException&) {
        return BAD_DATE;
    }
}

int format_http_date(char buf[], size_t size, time_t when); 
char* format_http_date(time_t when, char* buf, size_t len);

TString FormatHttpDate(time_t when);