php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #54851
Patch php-datetime-bug54851.diff-v2 revision 2011-05-20 09:02 UTC by mats dot lindh at gmail dot com
Patch php-datetime-bug54851.diff revision 2011-05-19 12:58 UTC by mats dot lindh at gmail dot com

Patch php-datetime-bug54851.diff for Date/time related Bug #54851

Patch version 2011-05-19 12:58 UTC

Return to Bug #54851 | Download this patch
This patch is obsolete

Obsoleted by patches:

Patch Revisions:

Developer: mats.lindh@gmail.com

Index: ext/date/tests/bug54851.phpt
===================================================================
--- ext/date/tests/bug54851.phpt	(revision 0)
+++ ext/date/tests/bug54851.phpt	(revision 0)
@@ -0,0 +1,12 @@
+--TEST--
+Bug #54851 (DateTime::createFromFormat() uses today for "D")
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+$date = new \DateTime("2008-07-08T22:14:12+02:00");
+$date2 = \DateTime::createFromFormat("D", $date->format("D"));
+
+var_dump($date->format("D") == $date2->format("D"));
+--EXPECT--
+bool(true)
Index: ext/date/lib/parse_date.re
===================================================================
--- ext/date/lib/parse_date.re	(revision 311245)
+++ ext/date/lib/parse_date.re	(working copy)
@@ -1854,6 +1854,7 @@
 	char       *ptr = string;
 	char       *begin;
 	timelib_sll tmp;
+	const timelib_relunit* tmprelunit = 0;
 	Scanner in;
 	Scanner *s = &in;
 	int allow_extra = 0;
@@ -1885,9 +1886,15 @@
 		switch (*fptr) {
 			case 'D': /* three letter day */
 			case 'l': /* full day */
-				if (!timelib_lookup_relunit((char **) &ptr)) {
+				tmprelunit = timelib_lookup_relunit((char**) &ptr);
+				if (!tmprelunit) {
 					add_pbf_error(s, "A textual day could not be found", string, begin);
+					break;
 				}
+				in.time->have_relative = 1; 
+				in.time->relative.have_weekday_relative = 1;
+				in.time->relative.weekday = tmprelunit->multiplier;
+				in.time->relative.weekday_behavior = 1;
 				break;
 			case 'd': /* two digit day, with leading zero */
 			case 'j': /* two digit day, without leading zero */
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 19:01:53 2014 UTC