[patch] strptime(3) ISO 8601 compliance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <phg@xxxxxxxxxxxxx>
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@xxxxxxxxxxxxx>
---
 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: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux