I've a function which converts an RFC 822 timestamp to unixtime
#include <stdio.h>
#include <time.h>
int main() {
struct tm tm;
time_t unixtime;
strptime("Sun, 20 Feb 2011 10:28:02 +0800","%a, %e %h %Y %H:%M:%S %z",&tm);
unixtime = mktime(&tm);
printf("%d\n",unixtime);
return 0;
}
Problem: The timezone part (%z) doesn't seem to be working. I tried changing input timezone to other values +0100, + 0200 ect without changing other date values, it always gives the same unixtime stamp (ie, unixtimestamp corresponding to GMT)
What can be the issue here ?
struct tm does not contain a timezone field. %z is supported simply to support the same flags as strftime. You'll need to extract and adjust the timezone offset manually.