Bug #48225 [Asn->Ana]: DateTime parser doesn't set microseconds for "now"
| From: | cmb@php.net | Date: | Sun, 07 Aug 2016 14:11:05 +0000 |
| Subject: | Bug #48225 [Asn->Ana]: DateTime parser doesn't set microseconds for "now" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-203036@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=48225&edit=1
ID: 48225
Updated by: cmb@php.net
Reported by: knut dot urdalen at gmail dot com
Summary: DateTime parser doesn't set microseconds for "now"
-Status: Assigned
+Status: Analyzed
Type: Bug
Package: Date/time related
Operating System: *
PHP Version: 5.*, 6CVS (2009-05-09)
Assigned To: derick
Block user comment: N
Private report: N
New Comment:
The culprit is in php_date_initialize()[1]. time() delivers the
Unix timestamp in seconds, and timelib_unixtime2local() and some
other functions expect it this way. Actually, these functions in
timelib should be adjusted, but that would break API
compatibility.
A workaround would be to retrieve the current microseconds in
php_date_initialize() and to set now->f appropriately. This should
only be done, if the have_time member of the timelib_time struct
is 0, to avoid using the current microseconds, if a (partial) time
is already given.
However, due to bug #72773 and
<https://github.com/derickr/timelib/issues/7>
the attached patch
would cause BC breaks (what can be seen as some test cases fail
after applying the patch).
[1] <https://github.com/php/php-src/blob/PHP-7.0.10/ext/date/php_date.c#L2556>
Previous Comments:
------------------------------------------------------------------------
[2016-08-07 14:10:44] cmb@php.net
The following patch has been added/updated:
Patch Name: bug48225
Revision: 1470579044
URL: https://bugs.php.net/patch-display.php?bug=48225&patch=bug48225&revision=1470579044
------------------------------------------------------------------------
[2016-08-07 10:09:11] cmb@php.net
There are two similar but unrelated issues here.
Firstly, the microseconds are swallowed when formatting a datetime
using a locale with a decimal separator other than a dot. This has
already been analyzed in bug #67127.
Secondly, unless the microseconds are explicitly given, they are
simply set to 0 *internally*, see <https://3v4l.org/o4Lvt>. So
this is not related to formatting, but actually a parsing error.
Let's concentrate on this issue in this ticket.
------------------------------------------------------------------------
[2012-08-01 13:19:36] arnoonline at gmail dot com
I also have this bug within Linux Mint:
$ php -v
PHP 5.3.6-13ubuntu3.8 with Suhosin-Patch (cli) (built: Jun 13 2012 18:02:19)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
------------------------------------------------------------------------
[2012-05-14 11:38:43] tdenev at kontrax dot bg
OS: Slackware 13.37
$ php -v
PHP 5.3.8 (cli) (built: Oct 9 2011 13:58:17)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Xdebug v2.1.1, Copyright (c) 2002-2011, by Derick Rethans
still has this bug, the "u" part is still at 000000.
------------------------------------------------------------------------
[2012-02-24 17:46:14] kissifrot at gmail dot com
PHP 5.3.10 on Win32 still has the bug, the "u" part is still at 000000.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=48225
--
Edit this bug report at https://bugs.php.net/bug.php?id=48225&edit=1