logo       

Re: Bug in smarty_modifier_date_format: msg#00007

Subject: Re: Bug in smarty_modifier_date_format
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey,

you used smarty_make_time_stamp() which does not work.

I guess this is my fault because my initial diff contained that. You
must have missed my second mail:

">>>>>>> --- Danilo Buerger <danilo@xxxxxxxxxx> wrote:
>>>>>>>
>>>>>>> Small errata: it should be smarty_make_timestamp() instead of
>>>>>>> smarty_make_time_stamp() of course."

Greets

boots schrieb:
> Hi.
> 
> You convinced me and I have updated CVS accordingly.
> 
> Thanks a second time!
> 
> boots
> 
> --- Danilo Buerger <danilo@xxxxxxxxxx> wrote:
> Hey,
> 
> Even so strftime expects a unix timestamp ("The optional timestamp
> parameter is an integer Unix timestamp [...]" --
> http://de.php.net/strftime).
> 
> But as the manual says: "The only exception are mysql timestamps: They
> are also numeric only and 14 characters long (YYYYMMDDHHMMSS)" --
> http://smarty.php.net/manual/en/language.modifier.date.format.php.
> 
> print_r(strftime('%I', '20070101121212'));
> 
> Outputs "04".
> 
> Thats certainly not right. Thats why i think smarty_make_timestamp()
> should be called anyway. (I guess it was confusing because i was giving
> you a different mysql timestamp format than the manual says is allowed).
> 
> Greets
> 
> boots schrieb:
>>>> Hi.
>>>>
>>>> I think the manual is clear that only the numeric only version of the MySQL
>>>> timestamp is supported.
>>>> http://smarty.php.net/manual/en/language.modifier.date.format.php
>>>>
>>>> I say it is better to use MySQL's UNIX_TIMESTAMP(foo) for other (all)
> cases.
>>>> Personally, I vote against this change but I encourage others to comment.
>>>>
>>>> Best Regards!
>>>> boots
>>>>
>>>> --- Danilo Buerger <danilo@xxxxxxxxxx> wrote:
>>>>
>>>> "The TIMESTAMP data type has varying properties, depending on the MySQL
>>>> version and the SQL mode the server is running in. These properties are
>>>> described later in this section." --
>>>> http://dev.mysql.com/doc/refman/5.0/en/datetime.html
>>>>
>>>> For example (on 5.0.16):
>>>> | Field   | Type         | Null | Key | Default             | Extra
>>>>      |
>>>> | date    | timestamp    | YES  |     | 0000-00-00 00:00:00 |
>>>>      |
>>>>
>>>> But either way if its a datetime or a timestamp applying
>>>> smarty_make_timestamp to it still solves the problem.
>>>>
>>>> boots schrieb:
>>>>>>> Hi.
>>>>>>>
>>>>>>> That looks like a MySQL datetime rather than a timestamp. Otherwise,
> looks
>>>>>>> good. I've committed the %R fix to CVS.
>>>>>>>
>>>>>>> Thanks!
>>>>>>>
>>>>>>> boots
>>>>>>>
>>>>>>> --- Danilo Buerger <danilo@xxxxxxxxxx> wrote:
>>>>>>>
>>>>>>> Small errata: it should be smarty_make_timestamp() instead of
>>>>>>> smarty_make_time_stamp() of course.
>>>>>>>
>>>>>>> Danilo Buerger schrieb:
>>>>>>>>>> Hello list,
>>>>>>>>>>
>>>>>>>>>> when using Smarty in a Windows environment (substr(PHP_OS,0,3) ==
> 'WIN')
>>>>>>>>>> and trying to format a MySQL timestamp (0000-00-00 00:00:00) an error
>>>>>>>>>> occurs because the string is passed to strftime() without applying
>>>>>>>>>> smarty_make_time_stamp() to the string first. Another bug occurs when
>>>>>>>>>> using the %R format (which is unknown to Windows, see
>>>>>>>>>>
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_strftime.2c_.wcsftime.asp)).
>>>>>>>>>> So here is the diff that should fix these problems:
>>>>>>>>>>
>>>>>>>>>> Index: smarty-2.6.16/plugins/modifier.date_format.php
>>>>>>>>>> ===================================================================
>>>>>>>>>> --- smarty-2.6.16/plugins/modifier.date_format.php      (revision 84)
>>>>>>>>>> +++ smarty-2.6.16/plugins/modifier.date_format.php      (working
> copy)
>>>>>>>>>> @@ -31,10 +31,10 @@
>>>>>>>>>>  function smarty_modifier_date_format($string, $format="%b %e, %Y",
>>>>>>>>>> $default_date=null)
>>>>>>>>>>  {
>>>>>>>>>>      if (substr(PHP_OS,0,3) == 'WIN') {
>>>>>>>>>> -        $hours = strftime('%I', $string);
>>>>>>>>>> +        $hours = strftime('%I', smarty_make_time_stamp($string));
>>>>>>>>>>          $short_hours = ( $hours < 10 ) ? substr( $hours, -1) :
> $hours;
>>>>>>>>>> -        $_win_from = array ('%e',  '%T',       '%D',        '%l');
>>>>>>>>>> -        $_win_to   = array ('%#d', '%H:%M:%S', '%m/%d/%y',
>>>>>>>>>> $short_hours);
>>>>>>>>>> +        $_win_from = array ('%e',  '%T',       '%D',        '%l',
>>>>>>>>>>    '%R');
>>>>>>>>>> +        $_win_to   = array ('%#d', '%H:%M:%S', '%m/%d/%y',
>>>>>>>>>> $short_hours, '%H:%M');
>>>>>>>>>>          $format = str_replace($_win_from, $_win_to, $format);
>>>>>>>>>>      }
>>>>>>>>>>      if($string != '') {
>>>>>>>>>>
>>>>>>>>>> Greets,
>>>>>>>>>>
>>>>>>>>>> Danilo Bürger
> --
> Smarty Development Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>>

> ____________________________________________________________________________________
> Yahoo! Music Unlimited
> Access over 1 million songs.
> http://music.yahoo.com/unlimited
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFpTMxrwsg9y2CBIURArRFAJ9vre3tmDnAmQitgIo2pok/eed2zgCfSYQn
3uDqD91qNDUh0cf/bUewdLQ=
=PFeO
-----END PGP SIGNATURE-----

-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe