Jump to:

22979 Posts in 11808 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » Bug with Zend_Date (Zend framework with SS 2.4.0) ?

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

Page: 1
Go to End
Author Topic: 1174 Views
  • Myrdhin
    Avatar
    Community Member
    67 Posts

    Bug with Zend_Date (Zend framework with SS 2.4.0) ? Link to this post

    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 ?

  • Myrdhin
    Avatar
    Community Member
    67 Posts

    Re: Bug with Zend_Date (Zend framework with SS 2.4.0) ? Link to this post

    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 ?

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Bug with Zend_Date (Zend framework with SS 2.4.0) ? Link to this post

    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

    1174 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.