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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Bug with Zend_Date (Zend framework with SS 2.4.0) ?


Go to End


3 Posts   1638 Views

Avatar
Myrdhin

Community Member, 70 Posts

21 June 2010 at 8:41pm

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

Community Member, 70 Posts

24 June 2010 at 3:32am

Edited: 24/06/2010 3:34am

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

1 - I've downloaded the minimale version

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

Forum Moderator, 801 Posts

2 July 2010 at 8:44am

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