日付を変換して確認するために次のことを行っていますが、次の日付がtrueとして検証され続ける理由がわかりません。
%d
だけチェックしません[01,31] + leading zeros
か?これを行うためのより良い、より正確な方法はありますか?
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main () {
struct tm tm;
char buffer [80];
char *str = "29/Jan/2012";
if (strptime (str, "%Y/%b/%d", &tm) == NULL)
exit(EXIT_FAILURE);
if (strftime (buffer,80,"%Y-%m-%d",&tm) == 0)
exit(EXIT_FAILURE);
printf("%s\n", buffer); // prints 29-01-20
return 0;
}