php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | |
Patch php-datetime-bug54851.diff for Date/time related Bug #54851Patch version 2011-05-19 12:58 UTC Return to Bug #54851 | Download this patchThis patch is obsolete Obsoleted by patches: Patch Revisions:Developer: mats.lindh@gmail.comIndex: 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 = ∈ 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 */ |
Copyright © 2001-2025 The PHP Group All rights reserved. |
Last updated: Thu Jan 30 21:01:32 2025 UTC |