This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/2] [BZ #16141] strptime: extend %z range to UTC+14:00


This is a fix for [BZ #16141] strptime %z offset restriction.

strptime supports the parsing of a timezone offset from UTC time into the
broken-out time field tm_gmtoff. It supports timezone offsets between
UTC-12:00 and UTC+12:00, returning an error (NULL) for values outside
that range.

However, there are valid international timezones outside the supported
range.  Extending the valid positive timezone offset to +14:00 allows
for the correct parsing of several timezone offsets including:

* Pacific/Auckland summer time (+13:00)
* Pacific/Kiritimati (+14:00)
* Pacific/Apia summer time (+14:00)

James

2014-12-02  James Perkins  james@loowit.net

	[BZ #16141]
	* time/strptime_l.c (__strptime_internal): Extend %z timezone
	offset range to UTC+14:00 to parse offsets typical of extreme
	Western Pacific timezones, like NZ and Samoa summer time and
	Christmas Island.

---
 time/strptime_l.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/time/strptime_l.c b/time/strptime_l.c
index b3a612e..2140c47 100644
--- a/time/strptime_l.c
+++ b/time/strptime_l.c
@@ -777,7 +777,11 @@ __strptime_internal (rp, fmt, tmp, statep LOCALE_PARAM)
 		  return NULL;
 		val = (val / 100) * 100 + ((val % 100) * 50) / 30;
 	      }
-	    if (val > 1200)
+	    /* minimum UTC-12, used aboard ships */
+	    if (neg && val > 1200)
+	      return NULL;
+	    /* maximum UTC+14, Pacific/Kiritimati and Pacific/Apia summer time */
+	    if (!neg && val > 1400)
 	      return NULL;
 	    tm->tm_gmtoff = (val * 3600) / 100;
 	    if (neg)
-- 
1.7.9.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]