Bug #12934 Updated: strftime() doesn't grok negative time_t
| From: | eru@php.net | Date: | Wed, 03 Jul 2002 23:25:52 +0000 |
| Subject: | Bug #12934 Updated: strftime() doesn't grok negative time_t | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-13049@lists.php.net to get a copy of this message | ||
ID: 12934
Updated by: eru@php.net
Reported By: rich@horde.org
-Status: Open
+Status: Verified
Bug Type: Date/time related
-Operating System: Linux 2.2.15 ppc
+Operating System: Linux
-PHP Version: 4.0.6
+PHP Version: 4.3.0-dev
New Comment:
strftime now returns false for negative values, but that doesn't solve
the inconsistency. I'm really undecided if this is a Date/Time-problem
or simply a lack of proper documentation.
Previous Comments:
------------------------------------------------------------------------
[2001-08-23 17:36:11] rich@horde.org
This:
echo strftime("%Y-%m-%d %H:%M:%S", -200000);
outputs an empty string. However, this:
$foo = localtime(-200000000); echo $foo[5]+1900;
outputs "1963" in Linux 2.2.15, but outputs an empty string in Win2k.
While negative time_t is undefined according to POSIX, time functions
should probably work consistently, and strftime() should never output
nothing. (That is, since there is no error condition documented for
strftime(), this:
echo strftime("HONK", -200000);
should /always/ output "HONK", even if the %-values end up empty
because of the undefined meaning of negative time values.)
So, either strftime with negative time values should work,
or localtime with negative time values should fail (and the rest of the
time functions made consistent with either decision). If it's decided
that negative time values are to cause the functions to fail, then
error conditions should probably be defined or documented for those
functions (and maybe even warnings?).
(To be clear, that's not "PHP is nonconforming", but rather
"undocumented and nonportable inconsistency amongst *time functions is
a particularly icky form of nasal demon".)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=12934&edit=1