Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Bug with Zend_Date (Zend framework with SS 2.4.0) ?


Reply

3 Posts   1240 Views

Avatar
Myrdhin

21 June 2010 at 8:41pm Community Member, 67 Posts

Hello,

I use a Date field in Silverstripe and i know Silverstripe 2.4.0 use Zend_Date. But i think there is a problem with dates 1848-02-** and Zend_Date : when i display these dates, Zend_Date add +1 day each time !?

I try this code to show the problem (i think it's not a silverstripe problem) :

<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
</head>
<body>

<?php

require_once 'Zend/Date.php';

$frDates = array(
   "31/01/1848",
   "01/02/1848",
   "02/02/1848",
   "03/02/1848",
   "01/03/1848"
);

$dates = array(
   "1848-01-31",
   "1848-02-01",
   "1848-02-02",
   "1848-02-03",
   "1848-03-01"
);

date_default_timezone_set('Europe/Paris');

print "<h1>Zend_Date (Zend Framework with Silverstripe 2.4.0)</h1>";
foreach($dates as $index => $date) {
   $oDate = new Zend_Date($date);
   $stroDate = $oDate->get('dd/MM/yyyy');
   
   $test = ($frDates[$index] !== $stroDate);
   $style = ($test ? ' style="color:red;" ' : '');
   $sign = ($test ? '!=' : '=');

   print "<div $style >" . $frDates[$index] . " $sign $stroDate</div>";
}

print "<h1>Test avec DateTime (PHP version " . phpversion() . ")</h1>";
foreach($dates as $index => $date) {
   $oDate = new DateTime($date);
   $stroDate = $oDate->format('d/m/Y');
   
   $test = ($frDates[$index] !== $stroDate);
   $style = ($test ? ' style="color:red;" ' : '');
   $sign = ($test ? '!=' : '=');
   print "<div $style >" . $frDates[$index] . " $sign $stroDate</div>";
}

?>

</body>
</html>

And the result :

Zend_Date (Zend Framework with Silverstripe 2.4.0)

31/01/1848 = 31/01/1848
*01/02/1848 != 02/02/1848
*02/02/1848 != 03/02/1848
*03/02/1848 != 04/02/1848
01/03/1848 = 01/03/1848

Test avec DateTime (PHP version 5.2.6-1+lenny8)

31/01/1848 = 31/01/1848
01/02/1848 = 01/02/1848
02/02/1848 = 02/02/1848
03/02/1848 = 03/02/1848
01/03/1848 = 01/03/1848

Snirf :'(
A solution ?

Avatar
Myrdhin

24 June 2010 at 3:32am (Last edited: 24 June 2010 3:34am), Community Member, 67 Posts

To resolve my problem, i've upgraded Zend to the last version (1.10.6)...

1 - I've downloaded the [url=http://framework.zend.com/releases/ZendFramework-1.10.6/ZendFramework-1.10.6-minimal.tar.gz]minimale version[/url]

2 - I've extracted the archive in a temp folder. I've got a "/tmp/ZendFramework-1.10.6-minimal" folder

3 - I've make a backup of my "sapphire/thirdparty/Zend"

mv sapphire/thirdparty/Zend sapphire/thirdparty/_Zend

4 - I've moved my last Zend version in "sapphire/thirdparty/Zend"

mv /tmp/ZendFramework-1.10.6-minimal/library/Zend sapphire/thirdparty/

It seem to work...

Do I have to modify something in Zend files so that it is compatible with Silverstripe 2.4.0/Sapphire ?

Avatar
Ingo

2 July 2010 at 8:44am Forum Moderator, 801 Posts

Weird - could you point us to the ticket or bugfix in Zend_framework that resolves this?
I've created a ticket for updating zend: http://open.silverstripe.org/ticket/5767