Re: [SMARTY] smarty date format error (on AMD64?)

From: Date: Wed, 09 Mar 2005 00:04:46 +0000
Subject: Re: [SMARTY] smarty date format error (on AMD64?)
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12309@lists.php.net to get a copy of this message
Why not put a check into the smarty_make_timestamp() function? It's predictable in that it returns huge timestamps (3441718022400 is an example). The check could (and should) be removed once PHP fixes what appears to be a fairly simple bug. So, until then, what do you do? Well, I've put together a simple fix. In plugins/shared.make_timestamp.php around line 51 there is something like this:
    $time = strtotime($string);
    if (is_numeric($time) && $time != -1) {
        return $time;
    }
Change that to:
    static $endOfTime;
    if (!isset($endOfTime)) {
        $endOfTime = mktime(3,14,6,1,19,2038); // End of 32-bit UNIX time - 1
                                               // 19 Jan 2038 at 03:14 and 7
    }
    $time = strtotime($string);
    if (is_numeric($time) && $time != -1 && $time < $endOfTime) {
        return $time;
    }
This fixed my problem since the function fails in a predictable format on my Opteron box. Of course, it will break if this code is still running after Jan of 2038. Works on Apache 2.0.53/PHP 4.3.10 under Debian GNU/Linux (2.6.8-10). Is there a place where I can add this to a Smarty bug database? I would assume this is becoming increasingly more common with the proliferation of Opterons and other lower end 64-bit processors. --Joe -- Joseph C. Stump joe@joestump.net http://www.joestump.net On Feb 1, 2005, at 12:43 AM, messju mohr wrote:
On Tue, Feb 01, 2005 at 01:17:43AM +0000, Abdul-Wahid Paterson wrote:
Hi, I have a date formating error with smarty on my AMD64 machine. When I use {$smarty.now|date_format:"%Y"} in my template it prints 110722 instead of 2005 I have several places in my code where I use $smarty.now with various fomatting options. All of them seem to be mucked up on my AMD64 machine but fine on my x86 machines using the same code base. Oh, and normal PHP dates work fine on my AMD64 e.g. print date("Y") prints 2005. Any ideas???
strtotime is broken on 64-bit machines: http://bugs.php.net/bug.php?id=30215
Abdul-Wahid
-- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


Attachment: [application/pkcs7-signature] smime.p7s
« previous php.smarty.general (#12309) next »