public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "seanp_oriordain at yahoo dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug libc/15100] New: strptime conversion error for %W Date: Tue, 05 Feb 2013 11:38:00 -0000 [thread overview] Message-ID: <bug-15100-131@http.sourceware.org/bugzilla/> (raw) http://sourceware.org/bugzilla/show_bug.cgi?id=15100 Bug #: 15100 Summary: strptime conversion error for %W Product: glibc Version: 2.15 Status: NEW Severity: normal Priority: P2 Component: libc AssignedTo: unassigned@sourceware.org ReportedBy: seanp_oriordain@yahoo.com CC: drepper.fsp@gmail.com Classification: Unclassified %W returns incorrect answers The code here: #define _XOPEN_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> int main (void) { struct tm tm; char buf[255]; memset (&tm, 0, sizeof (struct tm)); // ok what week number is the 1st of January 2012? // according to this it is week 01 in %U format // and 00 in %W format... strptime ("2012-01-01 01:00", "%Y-%m-$d %H:%M", &tm); strftime (buf, sizeof (buf), "%Y-%m-%d %U %W %a %b %H:%M", &tm); puts("To demonstrate the different week numbers in %U %W"); puts("Using format %Y-%m-%d %U %W %a %b %H:%M"); puts (buf); // to demonstrate it works strptime ("2012 02 Sun 01 00", "%Y %W %a %H %M", &tm); strftime (buf, sizeof (buf), "%Y-%m-%d %a %b %H %M", &tm); puts("\nUsing format %Y-%m-%d %a %b %H%M for 2012 02 Sun 01 00"); puts (buf); // but then the potential bug... strptime ("2012 01 Sun 01 00", "%Y %W %a %H %M", &tm); strftime (buf, sizeof (buf), "%Y-%m-%d %a %b %H %M", &tm); puts("\nUsing format %Y-%m-%d %a %b %H%M for 2012 01 Sun 01 00"); puts("and this is wrong..."); puts (buf); strptime ("2012 00 Sun 01 00", "%Y %W %a %H %M", &tm); strftime (buf, sizeof (buf), "%Y-%m-%d %a %b %H %M", &tm); puts("\nUsing format %Y-%m-%d %a %b %H %M for 2012 00 Sun 01 00"); puts("and this is VERY wrong..."); puts (buf); exit (EXIT_SUCCESS); } generates the following: To demonstrate the different week numbers in %U %W Using format %Y-%m-%d %U %W %a %b %H:%M 2012-01-00 01 00 Sun Jan 00:00 Using format %Y-%m-%d %a %b %H%M for 2012 02 Sun 01 00 2012-01-08 Sun Jan 01 00 Using format %Y-%m-%d %a %b %H%M for 2012 01 Sun 01 00 and this is wrong... 2012-01-01 Sun Jan 01 00 Using format %Y-%m-%d %a %b %H %M for 2012 00 Sun 01 00 and this is VERY wrong... 2012-00--371 Sun Saturday 01 00 -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
next reply other threads:[~2013-02-05 11:38 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-02-05 11:38 seanp_oriordain at yahoo dot com [this message] 2013-06-05 8:34 ` [Bug libc/15100] " schwab@linux-m68k.org 2014-06-13 18:54 ` fweimer at redhat dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-15100-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).