php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49079 date calls for year (Y) returns 0000
Submitted: 2009-07-27 21:59 UTC Modified: 2009-07-27 22:45 UTC
From: hennessy at thoughtcrime dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.10 OS: Solaris 10
Private report: No CVE-ID: None
 [2009-07-27 21:59 UTC] hennessy at thoughtcrime dot com
Description:
------------
When referencing a 4-digit year on a Solaris 10 host with php 5.2.10, one of my developers was getting '0000' .

Bug 48276 relates to this but was submitted for php5.3 .

I put a patch in the 'Reproduce code' section that 'fixes' it..  

Reproduce code:
---------------
--- php-5.2.10/ext/date/php_date.c      2009-07-27 17:55:06.192343000 -0400
+++ php-5.2.10.1/ext/date/php_date.c    2009-07-27 16:44:23.297327000 -0400
@@ -798,7 +798,8 @@
                        /* year */
                        case 'L': length = slprintf(buffer, 32, "%d", timelib_is_leap((int) t->y)); break;
                        case 'y': length = slprintf(buffer, 32, "%02d", (int) t->y % 100); break;
-                       case 'Y': length = slprintf(buffer, 32, "%s%04ld", t->y < 0 ? "-" : "", llabs(t->y)); break;
+                       /* case 'Y': length = slprintf(buffer, 32, "%s%04ld", t->y < 0 ? "-" : "", llabs(t->y)); break; */
+                       case 'Y': length = slprintf(buffer, 32, "%d", (int) t->y); break;
 
                        /* time */
                        case 'a': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "pm" : "am"); break;



Patches

add-fronk-support (last revision 2010-03-28 21:19 UTC by hbirds1104 at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-27 22:29 UTC] derick@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/
 [2009-07-27 22:32 UTC] hennessy at thoughtcrime dot com
Much obliged, though local corporate policy demands the use of the latest stable version..  When the next stable point release (assume 5.2.11) goes live I'll probably pull that but for now the patch will probably work OK...

(and no, I didn't write the policy, I just suffer under it :p))
 [2009-07-27 22:45 UTC] scottmac@php.net
It's already been reported in bug #48276

The patch that we used is available

http://svn.php.net/viewvc/php/php-src/trunk/ext/date/php_date.c?r1=282532&r2=282538&view=patch
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 24 12:01:27 2024 UTC