strptime(3) ISO 8601 compliance
PATCH 1/1 strptime(3) ISO 8601 compliance
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
From 57818307dc9ad8ecebc9517c26f800d3ae0cb0de Mon Sep 17 00:00:00 2001
From: Philipp Gesang <[email protected]>
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.)
--- man3/strptime.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
man3/strptime.3 +1 -1
@@ -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
Signature · 1 line
2.15.0