]>
git.ipfire.org Git - thirdparty/squid.git/blob - lib/iso3307.c
17 #define ASCII_DIGIT(c) ((c)-48)
20 parse_iso3307_time(const char *buf
)
22 /* buf is an ISO 3307 style time: YYYYMMDDHHMMSS or YYYYMMDDHHMMSS.xxx */
25 while (*buf
== ' ' || *buf
== '\t')
27 if ((int) strlen(buf
) < 14)
29 memset(&tms
, '\0', sizeof(struct tm
));
30 tms
.tm_year
= (ASCII_DIGIT(buf
[0]) * 1000) + (ASCII_DIGIT(buf
[1]) * 100) +
31 (ASCII_DIGIT(buf
[2]) * 10) + ASCII_DIGIT(buf
[3]) - 1900;
32 tms
.tm_mon
= (ASCII_DIGIT(buf
[4]) * 10) + ASCII_DIGIT(buf
[5]) - 1;
33 tms
.tm_mday
= (ASCII_DIGIT(buf
[6]) * 10) + ASCII_DIGIT(buf
[7]);
34 tms
.tm_hour
= (ASCII_DIGIT(buf
[8]) * 10) + ASCII_DIGIT(buf
[9]);
35 tms
.tm_min
= (ASCII_DIGIT(buf
[10]) * 10) + ASCII_DIGIT(buf
[11]);
36 tms
.tm_sec
= (ASCII_DIGIT(buf
[12]) * 10) + ASCII_DIGIT(buf
[13]);