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:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=0z+RcMyuZYt/3laGfFID2PIo0t9FGYJNLYjp3Rwk5wE=; b=gnZAdL43gD2rL3JyaHfcbzKvsAf0dng3s5QhTO8t4dCuEikyRpgO0llTmTs5OytNN64NwS5kchZ9OOaVfzDM297yTXlxpRnf1LyKo6X54Op9leNwRx0pduLQ1wQmnA2qGsq0H7lgXNG4/V8w4ZcewmnOj46lrOt5EcBvxgJ8wVA= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=CEYInV/gBkpND4Nof/cwuRHDQvSQw3HEFTlZC0utqHdn6Ce7/bBHxguIF3He2NJrWS8NRO61CaRTJUYP0bPJ/MsVSSJGrDOy+0iPmgTIiXxIVPVRY+Fv6S0vfAeuR2QZJ5EUkY0VkLjP7pTeT2nTN12z4Kchmuawb1odJ42+o4w= Thanks to the useful replies here. But I need to ask a final question:On Mac OSX and with 32 bit compile option, How to parse "Thu, 24-Apr-38 04:28:16 GMT" to struct tm or other structs like that? Do I need to down or write an alternative lib to parse it? I don't want to mix different quetions here,just want to make sure that I should forsake strptime right now. On Fri, Apr 25, 2008 at 2:58 AM, Terry Lambert <tlambert@apple.com> wrote:
On Apr 24, 2008, at 3:48 AM, Surf Chen wrote:
Martin Costabel wrote:
Well, on the Mac it only works if you compile for a 64bit architecture.
Does means that it internally uses the type time_t on mac osx?
You wrote "older than 1938" which is fine in English, but you did not
mean 1938, you meant 2038. If in your program you write 1938 instead of 38 and %Y instead of %y, everything is OK. If you write 2038 and %Y, you get the same problem as for 38 and %y.
oh...I make a big written mistake.
Luckily everybody here knows the real meaning.
Whether the date is before or after the Epoch depnds on the value and the range.
For a 32 bit signed time_t, the range is from -2^31 to 2^31.
<http://www.opengroup.org/onlinepubs/009695399/functions/strptime.html>
The only "bugs" I've seen so far in this thread are:
(1) the 64 bit version of the code should be interpreting a %y 2 digit 38 the same way as the 32 bit code, which is minorly forgivable, given that the UNIX certification process was done before all of the 64 bit support was dealt with, and humans who care about this sort of thing should be using %Y and 4 digit dates.
(2) the use of %Y and a 4 digit date on a system with a 32 bit time_t should arguably cause strptime() to return NULL, indicating a conversion error.
(3) the value for tm_year should arguably be "38" instead of "69" for the sample code, unless we are clamping down on pre-Epoch dates (I say arguably, since the code could be considered correct, either way).
All that said, I think I agree with Sun Microsystems that you should be using getdate() instead, since it has better conversion specification and error reporting:
<http://www.opengroup.org/onlinepubs/009695399/functions/getdate.html>
Please file a problem report about strptime().
-- Terry
_______________________________________________ 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