Source-Changes-HG archive

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

[src/trunk]: src The military/nautical time zones were added following RFC 82...



details:   https://anonhg.NetBSD.org/src/rev/50501aedc19d
branches:  trunk
changeset: 355953:50501aedc19d
user:      ginsbach <ginsbach%NetBSD.org@localhost>
date:      Thu Aug 24 01:01:09 2017 +0000

description:
The military/nautical time zones were added following RFC 822 and RFC
2822 specifications.  Unfortunately they are specified incorrectly in
RFC-822 and not very clearly in RFC 2822. RFC 1123 clearly states they
are specified incorrectly - counting the wrong way from UTC - in RFC
822.  RFC 2822 just states they were implemented in a non-standard way.
Mea culpa for not noticing when originally implemented.  Fix them so
the correct calculations are made.

diffstat:

 lib/libc/time/strptime.c         |  10 ++++----
 tests/lib/libc/time/t_strptime.c |  48 ++++++++++++++++++++--------------------
 2 files changed, 29 insertions(+), 29 deletions(-)

diffs (102 lines):

diff -r ea98716d3daf -r 50501aedc19d lib/libc/time/strptime.c
--- a/lib/libc/time/strptime.c  Wed Aug 23 22:27:55 2017 +0000
+++ b/lib/libc/time/strptime.c  Thu Aug 24 01:01:09 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: strptime.c,v 1.61 2017/08/12 03:29:23 ginsbach Exp $   */
+/*     $NetBSD: strptime.c,v 1.62 2017/08/24 01:01:09 ginsbach Exp $   */
 
 /*-
  * Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: strptime.c,v 1.61 2017/08/12 03:29:23 ginsbach Exp $");
+__RCSID("$NetBSD: strptime.c,v 1.62 2017/08/24 01:01:09 ginsbach Exp $");
 #endif
 
 #include "namespace.h"
@@ -521,11 +521,11 @@
                                        /* Argh! No 'J'! */
                                        if (*bp >= 'A' && *bp <= 'I')
                                                tm->TM_GMTOFF =
-                                                   ('A' - 1) - (int)*bp;
+                                                   (int)*bp - ('A' - 1);
                                        else if (*bp >= 'L' && *bp <= 'M')
-                                               tm->TM_GMTOFF = 'A' - (int)*bp;
+                                               tm->TM_GMTOFF = (int)*bp - 'A';
                                        else if (*bp >= 'N' && *bp <= 'Y')
-                                               tm->TM_GMTOFF = (int)*bp - 'M';
+                                               tm->TM_GMTOFF = 'M' - (int)*bp;
                                        tm->TM_GMTOFF *= SECSPERHOUR;
 #endif
 #ifdef TM_ZONE
diff -r ea98716d3daf -r 50501aedc19d tests/lib/libc/time/t_strptime.c
--- a/tests/lib/libc/time/t_strptime.c  Wed Aug 23 22:27:55 2017 +0000
+++ b/tests/lib/libc/time/t_strptime.c  Thu Aug 24 01:01:09 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_strptime.c,v 1.12 2015/10/31 02:25:11 christos Exp $ */
+/* $NetBSD: t_strptime.c,v 1.13 2017/08/24 01:01:09 ginsbach Exp $ */
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include <sys/cdefs.h>
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_strptime.c,v 1.12 2015/10/31 02:25:11 christos Exp $");
+__RCSID("$NetBSD: t_strptime.c,v 1.13 2017/08/24 01:01:09 ginsbach Exp $");
 
 #include <time.h>
 #include <stdlib.h>
@@ -126,28 +126,28 @@
        { "+1060",                      -1 },
        { "-1060",                      -1 },
 
-       { "A",                          -3600 },
-       { "B",                          -7200 },
-       { "C",                          -10800 },
-       { "D",                          -14400 },
-       { "E",                          -18000 },
-       { "F",                          -21600 },
-       { "G",                          -25200 },
-       { "H",                          -28800 },
-       { "I",                          -32400 },
-       { "L",                          -39600 },
-       { "M",                          -43200 },
-       { "N",                          3600 },
-       { "O",                          7200 },
-       { "P",                          10800 },
-       { "Q",                          14400 },
-       { "R",                          18000 },
-       { "T",                          25200 },
-       { "U",                          28800 },
-       { "V",                          32400 },
-       { "W",                          36000 },
-       { "X",                          39600 },
-       { "Y",                          43200 },
+       { "A",                          3600 },
+       { "B",                          7200 },
+       { "C",                          10800 },
+       { "D",                          14400 },
+       { "E",                          18000 },
+       { "F",                          21600 },
+       { "G",                          25200 },
+       { "H",                          28800 },
+       { "I",                          32400 },
+       { "L",                          39600 },
+       { "M",                          43200 },
+       { "N",                          -3600 },
+       { "O",                          -7200 },
+       { "P",                          -10800 },
+       { "Q",                          -14400 },
+       { "R",                          -18000 },
+       { "T",                          -25200 },
+       { "U",                          -28800 },
+       { "V",                          -32400 },
+       { "W",                          -36000 },
+       { "X",                          -39600 },
+       { "Y",                          -43200 },
 
        { "J",                          -2 },
 



Home | Main Index | Thread Index | Old Index