You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by rp...@apache.org on 2007/11/19 23:20:15 UTC
svn commit: r596464 - in /apr/apr-util/branches/1.2.x: CHANGES
misc/apr_date.c
Author: rpluem
Date: Mon Nov 19 14:20:15 2007
New Revision: 596464
URL: http://svn.apache.org/viewvc?rev=596464&view=rev
Log:
Merge r233425, r405896, r562892 from trunk:
Fix the parsing of several types of RFC style dates and add a new one.
* misc/apr_date.c
(apr_date_parse_rfc): correct the gmt offset for two formats, tweak some
comments, add a new date format, simplify gmtstr parsing.
* Cleanup and merge testdate (and testdaterfc) into the abts test suite
(testall).
* CHANGES: document change.
Submitted By: Maxime Petazzoni <maxime.petazzoni bulix.org>
Tweaked By: Garrett Rooney, davi
Reviewed by: rpluem
Modified:
apr/apr-util/branches/1.2.x/CHANGES
apr/apr-util/branches/1.2.x/misc/apr_date.c
Modified: apr/apr-util/branches/1.2.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.2.x/CHANGES?rev=596464&r1=596463&r2=596464&view=diff
==============================================================================
--- apr/apr-util/branches/1.2.x/CHANGES [utf-8] (original)
+++ apr/apr-util/branches/1.2.x/CHANGES [utf-8] Mon Nov 19 14:20:15 2007
@@ -6,6 +6,9 @@
Changes with APR-util 1.2.12
+ *) Fix GMT offset for several date formats and add a new format.
+ [Maxime Petazzoni <maxime.petazzoni bulix.org>]
+
*) Numerous fixes to the test/ framework, including better handling of
long size_t comparisons and more consistent Makefile.(in|win) setup
for authoring new tests. [William Rowe]
Modified: apr/apr-util/branches/1.2.x/misc/apr_date.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.2.x/misc/apr_date.c?rev=596464&r1=596463&r2=596464&view=diff
==============================================================================
--- apr/apr-util/branches/1.2.x/misc/apr_date.c (original)
+++ apr/apr-util/branches/1.2.x/misc/apr_date.c Mon Nov 19 14:20:15 2007
@@ -334,7 +334,7 @@
if (!date)
return APR_DATE_BAD;
- /* Not all dates have text months at the beginning. */
+ /* Not all dates have text days at the beginning. */
if (!apr_isdigit(date[0]))
{
while (*date && apr_isspace(*date)) /* Find first non-whitespace char */
@@ -361,7 +361,7 @@
monstr = date + 3;
timstr = date + 12;
- gmtstr = date + 20;
+ gmtstr = date + 21;
TIMEPARSE_STD(ds, timstr);
}
@@ -418,7 +418,9 @@
}
else if (apr_date_checkmask(date, "## @$$ ## ##:##:## *")) {
/* This is the old RFC 1123 date format - many many years ago, people
- * used two-digit years. Oh, how foolish. */
+ * used two-digit years. Oh, how foolish.
+ *
+ * Two-digit day, two-digit year version. */
ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0');
if (ds.tm_year < 70)
@@ -432,9 +434,29 @@
TIMEPARSE_STD(ds, timstr);
}
+ else if (apr_date_checkmask(date, " # @$$ ## ##:##:## *")) {
+ /* This is the old RFC 1123 date format - many many years ago, people
+ * used two-digit years. Oh, how foolish.
+ *
+ * Space + one-digit day, two-digit year version.*/
+ ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0');
+
+ if (ds.tm_year < 70)
+ ds.tm_year += 100;
+
+ ds.tm_mday = (date[1] - '0');
+
+ monstr = date + 3;
+ timstr = date + 10;
+ gmtstr = date + 19;
+
+ TIMEPARSE_STD(ds, timstr);
+ }
else if (apr_date_checkmask(date, "# @$$ ## ##:##:## *")) {
/* This is the old RFC 1123 date format - many many years ago, people
- * used two-digit years. Oh, how foolish. */
+ * used two-digit years. Oh, how foolish.
+ *
+ * One-digit day, two-digit year version. */
ds.tm_year = ((date[6] - '0') * 10) + (date[7] - '0');
if (ds.tm_year < 70)
@@ -521,7 +543,7 @@
monstr = date + 3;
timstr = date + 12;
- gmtstr = date + 20;
+ gmtstr = date + 21;
TIMEPARSE_STD(ds, timstr);
}
@@ -583,22 +605,21 @@
* If there is any confusion, tm_gmtoff will remain 0.
*/
ds.tm_gmtoff = 0;
- if (gmtstr && *gmtstr != '\0') {
- /* Do we have a GMT? */
- if (*(++gmtstr) != '\0') {
- int offset;
- switch (*(gmtstr++)) {
- case '-':
- offset = atoi(gmtstr);
- ds.tm_gmtoff -= (offset / 100) * 60 * 60;
- ds.tm_gmtoff -= (offset % 100) * 60;
- break;
- case '+':
- offset = atoi(gmtstr);
- ds.tm_gmtoff += (offset / 100) * 60 * 60;
- ds.tm_gmtoff += (offset % 100) * 60;
- break;
- }
+
+ /* Do we have a timezone ? */
+ if (gmtstr) {
+ int offset;
+ switch (*gmtstr) {
+ case '-':
+ offset = atoi(gmtstr+1);
+ ds.tm_gmtoff -= (offset / 100) * 60 * 60;
+ ds.tm_gmtoff -= (offset % 100) * 60;
+ break;
+ case '+':
+ offset = atoi(gmtstr+1);
+ ds.tm_gmtoff += (offset / 100) * 60 * 60;
+ ds.tm_gmtoff += (offset % 100) * 60;
+ break;
}
}