Doc #51538 [Com]: strptime() buggy prior PHP 5.2.0
| From: | alex dot schuch at gmx dot de | Date: | Thu, 12 Aug 2010 12:54:01 +0000 |
| Subject: | Doc #51538 [Com]: strptime() buggy prior PHP 5.2.0 | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-4847@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51538&edit=1
ID: 51538
Comment by: alex dot schuch at gmx dot de
Reported by: alex dot schuch at gmx dot de
Summary: strptime() buggy prior PHP 5.2.0
Status: Open
Type: Documentation Problem
Package: Documentation problem
Operating System: irrelevant?
PHP Version: Irrelevant
Block user comment: N
New Comment:
I just had a look at the PHP source:
svn diff -c218534 ext/standard/datetime.c
The fix to this problem was the initialisation of the struct with zero
(using memset()).
From the manual "man 3 strptime":
In principle, this function does not initialize tm but only stores the
values specified. This means that tm should be initialized before the
call. Details differ a bit between different Unix systems. The glibc
implementation does not touch those fields which are not explicitly
specified, except that it recomputes the tm_wday and tm_yday field if
any of the year, month, or day elements changed.
So in easy words:
The elements of the struct are not initialised. strptime() only sets the
values according to the pattern so that non-given values were not
overwritten - they stayed at their uninitialised value.
Previous Comments:
------------------------------------------------------------------------
[2010-08-10 19:13:37] philip@php.net
Surely it's not "random", so is there some logic behind these incorrect
[and
seemingly random] values prior to 5.2.0? Or maybe we could use the word
'undefined' instead. Thoughts?
The changelog entry is "strptime() does not initialize the internal date
storage
structure" although I'm unsure exactly what that means.
------------------------------------------------------------------------
[2010-04-12 11:10:58] alex dot schuch at gmx dot de
Description:
------------
A note should be added to strptime() documentation, as the function is
not
working according to the documentation before PHP 5.2.0.
http://bugs.php.net/38524
http://php.net/ChangeLog-5.php
Maybe something like:
Prior PHP 5.2.0, strptime() returns random values for parts not included
in the
format string (see bug #38524).
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51538&edit=1