ID:               28543
 Updated by:       [EMAIL PROTECTED]
 Reported By:      rjones-php-ibase-bug at ico dot viva dot org
-Status:           Open
+Status:           Bogus
 Bug Type:         InterBase related
 Operating System: windows 2000 and Linux
 PHP Version:      4.3.6
 New Comment:

Apparently, the Windows and GNU implementations of strftime() behave
differently. Nothing we can do about that. You can use ibase_timefmt()
to change the way strftime() is applied.

BTW, your patch sucks. You're using tm_year, which holds the number of
years since 1900, and comparing it < 10, causing '1900' to be printed
as '0001900'. Please don't post untested crap here.


Previous Comments:
------------------------------------------------------------------------

[2004-05-27 16:54:47] rjones-php-ibase-bug at ico dot viva dot org

Description:
------------
This function does not work consistently on Linux and Windows 2000 with
dates with small years.

The strings it returns are
under Linux: "01/01/1"
under Windows: "01/01/0001"

I have traced this back:
        ibase_fetch_row -> _php_ibase_fetch_hash -> _php_ibase_var_zval ->
strftime

in interbase.c at line 1919:

#if HAVE_STRFTIME
                                Z_STRLEN_P(val) = strftime(string_data, 
sizeof(string_data),
format, &t);
#else
                                /* FIXME */
                                if (!t.tm_hour && !t.tm_min && !t.tm_sec) {
                                        Z_STRLEN_P(val) = sprintf(string_data, 
"%02d/%02d/%4d", t.tm_mon +
1, t.tm_mday, t.tm_year + 1900);
                                } else {
                                        Z_STRLEN_P(val) = sprintf(string_data, 
"%02d/%02d/%4d
%02d:%02d:%02d", t.tm_mon+1, t.tm_mday, t.tm_year + 1900, t.tm_hour,
t.tm_min, t.tm_sec);
                                }
#endif

As a work-around, I've used 

#if HAVE_STRFTIME
// Make this consistent with PHP on windows.
// FixMe This should give consistent results for all years from 0001
onwards
                                if(t.tm_year < 10)      
                                {
                                        if (!t.tm_hour && !t.tm_min && !t.tm_sec) {
                                                Z_STRLEN_P(val) = sprintf(string_data, 
"%02d/%02d/000%d",
t.tm_mon + 1, t.tm_mday, t.tm_year+1900);
                                        } else {
                                                Z_STRLEN_P(val) = sprintf(string_data, 
"%02d/%02d/000%d
%02d:%02d:%02d", t.tm_mon+1, t.tm_mday, t.tm_year+1900, t.tm_hour,
t.tm_min, t.tm_sec);
                                        }
                                }
                                else
                                {
                                        Z_STRLEN_P(val) = strftime(string_data, 
sizeof(string_data),
format, &t);
                                }
#else
                                /* FIXME */
                                if (!t.tm_hour && !t.tm_min && !t.tm_sec) {
                                        Z_STRLEN_P(val) = sprintf(string_data, 
"%02d/%02d/%4d", t.tm_mon +
1, t.tm_mday, t.tm_year + 1900);
                                } else {
                                        Z_STRLEN_P(val) = sprintf(string_data, 
"%02d/%02d/%4d
%02d:%02d:%02d", t.tm_mon+1, t.tm_mday, t.tm_year + 1900, t.tm_hour,
t.tm_min, t.tm_sec);
                                }
#endif


Reproduce code:
---------------
$rs_temp=ibase_query("SELECT time_stamp_field FROM
some_stored_procedure()"); 
$row_temp=ibase_fetch_row($rs_temp);
print($row_temp[0]); 

Expected result:
----------------
01/01/0001

Actual result:
--------------
01/01/1


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28543&edit=1

Reply via email to