From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12535 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] strptime: Add %F format (glibc extension). Date: Thu, 22 Feb 2018 18:44:41 -0500 Message-ID: <20180222234441.GG1436@brightrain.aerifal.cx> References: <20180222215339.11414-1-przemoc@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1519342978 13131 195.159.176.226 (22 Feb 2018 23:42:58 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 22 Feb 2018 23:42:58 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-12551-gllmg-musl=m.gmane.org@lists.openwall.com Fri Feb 23 00:42:54 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1ep0Vn-0002h4-0W for gllmg-musl@m.gmane.org; Fri, 23 Feb 2018 00:42:51 +0100 Original-Received: (qmail 25794 invoked by uid 550); 22 Feb 2018 23:44:53 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 25773 invoked from network); 22 Feb 2018 23:44:53 -0000 Content-Disposition: inline In-Reply-To: <20180222215339.11414-1-przemoc@gmail.com> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:12535 Archived-At: On Thu, Feb 22, 2018 at 10:53:39PM +0100, Przemyslaw Pawelczyk wrote: > %F is a shortcut for %Y-%m-%d, the ISO 8601 date format. > It's already present in POSIX's strftime(), so it makes sense to support > it in a converse function too. > --- > > I'm not subscribed to ML, so please CC me in case of replying. > > src/time/strptime.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/src/time/strptime.c b/src/time/strptime.c > index c54a0d8c4c52..2c0d45574819 100644 > --- a/src/time/strptime.c > +++ b/src/time/strptime.c > @@ -59,6 +59,10 @@ char *strptime(const char *restrict s, const char *restrict f, struct tm *restri > s = strptime(s, "%m/%d/%y", tm); > if (!s) return 0; > break; > + case 'F': > + s = strptime(s, "%Y-%m-%d", tm); > + if (!s) return 0; > + break; > case 'H': > dest = &tm->tm_hour; > min = 0; Not having looked at this function in a while, I was doubtful the above would work, but in fact it looks like it does (analogous to the above case). While lots of this function is underspecified, the contract for the return value is well-designed. The want_century logic may be incomplete for %D and now %F, though. If so that's a separate issue from lack of %F extension and should be fixed in a separate patch. I think %F just needs to set want_century to 0, but %D might have more work to do. Rich