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

后端 未结 2 1882
再見小時候
再見小時候 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条回答
  • 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

    0 讨论(0)
  • 2021-01-21 18:50

    If it's available in your target system (eg Linux) you can use strptime.

    0 讨论(0)
提交回复
热议问题