What is an easy way to parse a date Http Header in C?

后端 未结 2 1886
再見小時候
再見小時候 2021-01-21 18:24

I want to parse an email http date header, is there an easy way to do it without writing my own string parsing functions?

Example:

Date: Fri, 19 Mar 2010         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-21 18:38

    libcurl has a function for that, too:

    time_t curl_getdate(char *datestring, time_t *now );
    

    If you don't want to link the whole library, you can just copy the code for that from here: https://github.com/curl/curl/blob/master/lib/parsedate.c

提交回复
热议问题