strptime cannot parse date older than 1938
strptime cannot parse date older than 1938
- Subject: strptime cannot parse date older than 1938
- From: "Surf Chen" <email@hidden>
- Date: Thu, 24 Apr 2008 13:09:18 +0800
If the parsing date > certain date,the strptime dose not work like it on linux.
date.c:
#include <stdio.h>
#include <string.h>
#include <time.h>
int main() {
char *date_str="Thu, 24-Apr-38 04:28:16 GMT";
struct tm tm;
memset(&tm,0,sizeof(tm));
strptime(date_str,"%a, %d-%b-%y %H:%M:%S %Z",&tm);
printf("%d\n",tm.tm_year);
return 0;
}
gcc -o date date.c
On my debian box, the output is 138
but on Mac OSX,output is 70.
The manpage(man 3 strptime) says:
Two-digit year values, including formats %y and %D, are now interpreted
as beginning at 1969 per POSIX requirements. Years 69-00 are interpreted
in the 20th century (1969-2000), years 01-68 in the 21st century
(2001-2068).
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden