strptime cannot parse date older than 1938
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=mAiVxYaS4ZBOsRAM1QuuuMOWavwLqCF7H92V/r3vAME=; b=fRxRq9aMYdJTPAMa6pyGSYNWOxvuhoWsEEwPVRMmTjr26hIU+3+wvQ4pl3NMdQONOkA+m/aVTxXP1Ps3kr3ONzwbQojHSt+zIEGSJg3s+rJUqozY+1u8+EEIpj8B/uu1oEkxhfmo/3F4wBB2fuC8NHfsFbb2hEs0qAaSOMTpeYE= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=shs/OcLYNn2SpCiqXJ4tF6CSZEeinKXPh7yW9n/HrYQofv1nGUZvZtU2yP0VBfGglRfWHqQ1R4bC5kx1sOMIkOR3eJ/7gjH3Ypf61SD21wjUwNTrXJ/+N1nyqvoEIZU2rP62xf7BaFI5PY7FNBHR+MTd9EHCgquXF8D8j+N6WMY= 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Surf Chen