dtparser.c
/*
  rfc5322_date_parse():
   Given a date time string in RFC 5322 format, this function
   parses and converts it into time_t format.

 On Success: Returns the number of characters from the date string parsed
 On Failure: Returns -1
 */
Given a date time string in RFC 5322 format, this function
parses and converts it into time_t format.

On Success: Returns the number of characters from the date string parsed
On Failure: Returns -1
Given a date time string in RFC 5322 format this function parses and converts it into time_t format . On Success : Returns the number of characters from the date string parsed On Failure : Returns - 1
int rfc5322_date_parse(const char *str, size_t len, time_t *t, bool usetime)
{
        struct tbuf buf;
        struct tm tm;
        time_t tmp_time;
        int tzone_offset;
        if (!str)
                goto baddate;
        memset(&tm, 0, sizeof(struct tm));
        *t = 0;
        buf.str = str;
        buf.len = len;
        buf.offset = 0;
        if (tokenise_and_create_tm(&buf, &tm, &tzone_offset, usetime) == -1)
                goto baddate;
        if (usetime)
                tmp_time = timegm(&tm);
        else
                tmp_time = mktime(&tm);
        if (tmp_time == -1)
                goto baddate;
        *t = tmp_time - tzone_offset * 60;
        return buf.offset;
baddate:
        return -1;
}
int rfc5322_date_parse ( const char * str , size_t len , time_t * t , bool usetime ) { struct tbuf buf ; struct tm tm ; time_t tmp_time ; int tzone_offset ; if ( ! str ) goto baddate ; memset ( & tm , 0 , sizeof ( struct tm ) ) ; * t = 0 ; buf . str = str ; buf . len = len ; buf . offset = 0 ; if ( tokenise_and_create_tm ( & buf , & tm , & tzone_offset , usetime ) == -1 ) goto baddate ; if ( usetime ) tmp_time = timegm ( & tm ) ; else tmp_time = mktime ( & tm ) ; if ( tmp_time == -1 ) goto baddate ; * t = tmp_time - tzone_offset * 60 ; return buf . offset ; baddate : return -1 ; }
rfc5322_date_parse():
Given a date time string in RFC 5322 format, this function
parses and converts it into time_t format.
rfc5322_date_parse () : Given a date time string in RFC 5322 format this function parses and converts it into time_t format .