|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-05-28 01:05 UTC] abies@php.net
[2004-05-28 16:12 UTC] rjones-php-ibase-bug at ico dot viva dot org
[2004-05-29 00:10 UTC] abies@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 08:00:01 2025 UTC |
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