ibm-aix에서 strptime함수가 이상해요~

kang1의 이미지

아래 코드를 aix에서 컴파일해서 돌렸더니 strptime이 이상하게 동작합니다.

#include <stdio.h>
#include <time.h>
 
 
int main()
{
struct tm tm;
time_t t;
 
strptime("20090728", "%Y%m%d", &tm)
 
printf("year: %d; month: %d; day: %d;\n",
        tm.tm_year, tm.tm_mon, tm.tm_mday);
 
return 0;
}

aix->
year: 20088801; month: -559038737; day: 0;

linux->
year: 109; month: 6; day: 28;

이것저것 해봤는데 aix경우에는 20090728와 같이 연속되어진 문자열을 구분못합니다.
2009 07 28 이라고 하면 날자값이 time_t 구조체에 정상적으로 들어 가더군요..
근데 linux에서는 붙여서도 위 결과 처럼 구조체에 정상적으로 값이 들어 가네요.. 황당..

bushi의 이미지

http://www.opengroup.org/onlinepubs/7990989775/xsh/strptime.html
SUSv2 군요.

Quote:

char *strptime(const char *buf, const char *format, struct tm *tm);

The format is ... . There must be white-space or other non-alphanumeric characters between any two conversion specifications.

OTL