com php-src: Fix bug #65554 in DateTime, when use it with D/l in format and textual day have dot at the end: ext/date/lib/parse_date.c
ext/date/lib/parse_date.re ext/date/tests/DateTime_f ix_createFromFormat.phpt
| From: | Anatol Belski | Date: | Wed, 16 Oct 2013 08:16:09 +0000 |
| Subject: | com php-src: Fix bug #65554 in DateTime, when use it with D/l in format and textual day have dot at the end: ext/date/lib/parse_date.c ext/date/lib/parse_date.re ext/date/tests/DateTime_f ix_createFromFormat.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-73567@lists.php.net to get a copy of this message | ||
Commit: 62b0f1d0fc79d98ddf03eacb5be0d0faabd992a0
Author: gron1987 <vlogvinskiy@cogniance.com> Wed, 28 Nov 2012 12:19:42 +0200
Committer: Anatol Belski <ab@php.net> Wed, 16 Oct 2013 01:16:09 -0700
Parents: 66dd725ac7044fd6a7698dd09a09fa49f2c7551e
Branches: str_size_and_int64
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=62b0f1d0fc79d98ddf03eacb5be0d0faabd992a0
Log:
Fix bug #65554 in DateTime, when use it with D/l in format and textual day have dot at the end
Bugs:
https://bugs.php.net/65554
Changed paths:
M ext/date/lib/parse_date.c
M ext/date/lib/parse_date.re
A ext/date/tests/DateTime_fix_createFromFormat.phpt
Diff:
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c
index 8f70748..d20029d 100644
--- a/ext/date/lib/parse_date.c
+++ b/ext/date/lib/parse_date.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Fri Apr 26 11:10:28 2013 */
+/* Generated by re2c 0.13.5 on Sun Aug 25 14:46:08 2013 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
@@ -616,7 +616,8 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr)
char *begin = *ptr, *end;
const timelib_relunit *tp, *value = NULL;
- while (**ptr != '\0' && **ptr != ' ' && **ptr != ','
&& **ptr != '\t') {
+ while (**ptr != '\0' && **ptr != ' ' && **ptr != ','
&& **ptr != '\t' && **ptr != ';' && **ptr !=
':' &&
+ **ptr != '/' && **ptr != '.' && **ptr !=
'-' && **ptr != '(' && **ptr != ')' ) {
++*ptr;
}
end = *ptr;
diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re
index 014f6a0..7efeb43 100644
--- a/ext/date/lib/parse_date.re
+++ b/ext/date/lib/parse_date.re
@@ -614,7 +614,8 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr)
char *begin = *ptr, *end;
const timelib_relunit *tp, *value = NULL;
- while (**ptr != '\0' && **ptr != ' ' && **ptr != ','
&& **ptr != '\t') {
+ while (**ptr != '\0' && **ptr != ' ' && **ptr != ','
&& **ptr != '\t' && **ptr != ';' && **ptr !=
':' &&
+ **ptr != '/' && **ptr != '.' && **ptr !=
'-' && **ptr != '(' && **ptr != ')' ) {
++*ptr;
}
end = *ptr;
diff --git a/ext/date/tests/DateTime_fix_createFromFormat.phpt
b/ext/date/tests/DateTime_fix_createFromFormat.phpt
new file mode 100644
index 0000000..abde292
--- /dev/null
+++ b/ext/date/tests/DateTime_fix_createFromFormat.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test fix for DateTime when date have textual day with dot or other special char at end
+--FILE--
+<?php
+
+//Set the default time zone
+date_default_timezone_set('Europe/London');
+
+echo "*** Testing clone on DateTime objects ***\n";
+
+// Create a DateTime object..
+$orig = new DateTime('2012-11-29 17:00:00');
+
+// String to parse
+$string = "Thu., Nov. 29, 2012 5:00PM";
+
+// Create a DateTime object from format
+$fromFormat = DateTime::createFromFormat( "D., M# j, Y g:iA", $string );
+
+echo "Format method: " . $orig->format("D., M. j, Y g:iA") . "\n";
+echo "createFromFormat method: " . $fromFormat->format("D., M. j, Y g:iA") .
"\n";
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing clone on DateTime objects ***
+Format method: Thu., Nov. 29, 2012 5:00PM
+createFromFormat method: Thu., Nov. 29, 2012 5:00PM
+===DONE===