From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9991 invoked by alias); 11 May 2011 14:52:36 -0000 Received: (qmail 9983 invoked by uid 22791); 11 May 2011 14:52:35 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.lysator.liu.se (HELO mail.lysator.liu.se) (130.236.254.3) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 May 2011 14:52:20 +0000 Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 6129340016 for ; Wed, 11 May 2011 16:52:18 +0200 (CEST) Received: from [192.168.0.33] (h57n3fls301o1095.telia.com [81.230.178.57]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 30C8140002 for ; Wed, 11 May 2011 16:52:18 +0200 (CEST) Message-ID: <4DCAA2A0.6040506@lysator.liu.se> Date: Wed, 11 May 2011 14:52:00 -0000 From: Peter Rosin User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: cygwin@cygwin.com Subject: strptime doesn't fill in tm_wday and tm_yday. Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2011-05/txt/msg00159.txt.bz2 Hello! The following STC hints at a problem in strptime: -----------------------8<---------------------------- #include #include int main(void) { /* seed tm with some garbage */ struct tm tm = { 0, 0, 0, /* s m h */ 0, 0, 0, /* d m y */ 290774, 2280577, 81 }; const char date[] = "2011-05-11 14:06:11"; if (!strptime(date, "%Y - %m - %d %T", &tm)) { fprintf(stderr, "strptime error\n"); return 1; } printf("%s", asctime(&tm)); printf("tm_yday %d\n", tm.tm_yday); printf("tm_wday %d\n", tm.tm_wday); printf("tm_isdst %d\n", tm.tm_isdst); return 0; } -----------------------8<---------------------------- I get this output with Cygwin 1.7.9-1: May 11 14:06:11 2011 tm_yday 2280577 tm_wday 290774 tm_isdst 81 I expect: Wed May 11 14:06:11 2011 tm_yday 130 tm_wday 3 tm_isdst whatever I get the expected output on the Linux host I tried (with tm_isdst=81), but not on Solaris 10. On Solaris 10 I get (for completeness): Sun May 11 14:06:11 2011 tm_yday 0 tm_wday 0 tm_isdst 0 Opengroup has this to say about only filling in some fields: "It is unspecified whether multiple calls to strptime() using the same tm structure will update the current contents of the structure or overwrite all contents of the structure. Conforming applications should make a single call to strptime() with a format and all data needed to completely specify the date and time being converted." but I don't think it applies since indeed I do completely specify the date in my strptime call. In my "real" program, the call to asctime with the crippled tm causes a seg-fault instead of "just" missing weekday output, I guess it depends... Cheers, Peter -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple