All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] strptime(3) ISO 8601 compliance
@ 2017-11-19 19:58 Philipp Gesang
  0 siblings, 0 replies; only message in thread
From: Philipp Gesang @ 2017-11-19 19:58 UTC (permalink / raw)
  To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA


[-- 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 --]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-11-19 19:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-19 19:58 [patch] strptime(3) ISO 8601 compliance Philipp Gesang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.