linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philipp Gesang <phg-seE3WNHshEcXhy9q4Lf3Ug@public.gmane.org>
To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [patch] strptime(3) ISO 8601 compliance
Date: Sun, 19 Nov 2017 20:58:55 +0100	[thread overview]
Message-ID: <20171119195855.GA20953@lethe> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 432 bytes --]

Hi,

strptime.3 claims %F is both ISO 8601 compliant and equivalent to
%Y-%m-%d. Since the standard permits a leading dash character to
indicate negative years [0], this can’t be both true.

%F with strftime prints negative years just fine though. Hence
I’m not sure if this is a bug in the docs or glibc.

Best,
Philipp

[0] http://www.loc.gov/standards/datetime/iso-tc154-wg5_n0039_iso_wd_8601-2_2016-02-16.pdf


[-- Attachment #1.2: 0001-strptime.3-clarify-behavior-of-F-with-negative-years.patch --]
[-- Type: text/plain, Size: 1208 bytes --]

From 57818307dc9ad8ecebc9517c26f800d3ae0cb0de Mon Sep 17 00:00:00 2001
From: Philipp Gesang <phg-seE3WNHshEcXhy9q4Lf3Ug@public.gmane.org>
Date: Sun, 19 Nov 2017 20:34:59 +0100
Subject: [PATCH] strptime.3: clarify behavior of %F with negative years

ISO 8601 explicitly allows for negative years:

    year = positiveYear | negativeYear | "0000" ;
    positiveYear = positiveDigit, digit, digit, digit
                   | ...
    negativeYear = "-", positiveYear ;

Thus for strptime, "%F" isn't strictly equivalent to the ISO 8601 year
format since it fails to handle the sign. (strftime "%F" has no problem
with negative years.)

Signed-off-by: Philipp Gesang <phg-seE3WNHshEcXhy9q4Lf3Ug@public.gmane.org>
---
 man3/strptime.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/man3/strptime.3 b/man3/strptime.3
index 6a82b04f4..b261e0736 100644
--- a/man3/strptime.3
+++ b/man3/strptime.3
@@ -363,7 +363,7 @@ This leads to
 .B %F
 Equivalent to
 .BR %Y-%m-%d ,
-the ISO 8601 date format.
+the ISO 8601 date format. (Parses only nonnegative year numbers.)
 .TP
 .B %g
 The year corresponding to the ISO week number, but without the century
-- 
2.15.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

                 reply	other threads:[~2017-11-19 19:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20171119195855.GA20953@lethe \
    --to=phg-see3wnhshecxhy9q4lf3ug@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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: link
Be 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 NNTP newsgroup(s).