Module Name: src
Committed By: ginsbach
Date: Thu Aug 24 01:01:09 UTC 2017
Modified Files:
src/lib/libc/time: strptime.c
src/tests/lib/libc/time: t_strptime.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/lib/libc/time/strptime.c
cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libc/time/t_strptime.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/time/strptime.c
diff -u src/lib/libc/time/strptime.c:1.61 src/lib/libc/time/strptime.c:1.62
--- src/lib/libc/time/strptime.c:1.61 Sat Aug 12 03:29:23 2017
+++ src/lib/libc/time/strptime.c Thu Aug 24 01:01:09 2017
@@ -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 @@ namedzone:
/* 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
Index: src/tests/lib/libc/time/t_strptime.c
diff -u src/tests/lib/libc/time/t_strptime.c:1.12 src/tests/lib/libc/time/t_strptime.c:1.13
--- src/tests/lib/libc/time/t_strptime.c:1.12 Sat Oct 31 02:25:11 2015
+++ src/tests/lib/libc/time/t_strptime.c Thu Aug 24 01:01:09 2017
@@ -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 @@ static struct {
{ "+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 },