php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21324 Date's convertTZbyID() is buggy
Submitted: 2003-01-01 20:46 UTC Modified: 2003-01-03 06:00 UTC
From: ross at netebb dot com Assigned:
Status: Closed Package: PEAR related
PHP Version: 4CVS-2003-01-01 (dev) OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
31 + 19 = ?
Subscribe to this entry?

 
 [2003-01-01 20:46 UTC] ross at netebb dot com
require_once 'Date/Date.php';
$date = new Date(time());
echo $date->format('%A %e of %B, %Y [%R %Z]'),"\n";
$date->convertTZbyID('US/Eastern');
echo $date->format('%A %e of %B, %Y [%R %Z]'),"\n";

produces:

Wednesday 1 of January, 2003 [18:39 PST]
Wednesday 01 of , 2003 [21:39 EST]

This patch will fix it:

Index: Date.php
===================================================================
RCS file: /repository/pear/Date/Date.php,v
retrieving revision 1.7
diff -u -r1.7 Date.php
--- Date.php    12 Nov 2002 18:11:10 -0000      1.7
+++ Date.php    2 Jan 2003 02:41:32 -0000
@@ -532,6 +532,9 @@
 
         list($this->year, $this->month, $this->day) =
             sscanf(Date_Calc::daysToDate($d), "%04s%02s%02s");
+        $this->year  = intval($this->year);
+        $this->month = intval($this->month);
+        $this->day   = intval($this->day);
     }
 
     /**
@@ -580,6 +583,9 @@
 
         list($this->year, $this->month, $this->day) =
             sscanf(Date_Calc::daysToDate($d), "%04s%02s%02s");
+        $this->year  = intval($this->year);
+        $this->month = intval($this->month);
+        $this->day   = intval($this->day);
     }
 
     /**

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-03 06:00 UTC] mj@php.net
This bug has been fixed in CVS and the changes will appear in the next release of PEAR::Date.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 15:01:28 2024 UTC