I tried using strptime() to parse dates in the ISO 8601 format (specified by "%F" or "%Y-%m-%d"), but when i read from the result struct tm i get absurd values for time, minutes and seconds. Here is an example code and the result:
char *s_date = (char *)malloc(sizeof(char) * 255);
scanf("%s", s_date);
struct tm bd_date;
strptime(s_date, "%Y-%m-%d", &bd_date)
printf("%d-%d-%d %d:%d:%d\n", (bd_date.tm_year + 1900), (bd_date.tm_mon + 1), bd_date.tm_mday, bd_date.tm_hour, bd_date.tm_min, bd_date.tm_sec);
The resulting output for the input "1990-05-01" is: 1990-5-1 2007659173:32766:1076394855, which show illegal values for tm_hour, tm_min and tm_sec. What am i doing wrong? is there something i'm missing? I though strptime() would automatically set the unused fields in the format to 0, but it seems like this isn't the case.