Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #970 #1002

Merged
merged 5 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 14 additions & 15 deletions adodb.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3395,7 +3395,7 @@ function DBDate($d, $isfld=false) {
$d = ADOConnection::UnixDate($d);
}

return adodb_date($this->fmtDate,$d);
return date($this->fmtDate,$d);
}

function BindDate($d) {
Expand Down Expand Up @@ -3437,7 +3437,7 @@ function DBTimeStamp($ts,$isfld=false) {

# strlen(14) allows YYYYMMDDHHMMSS format
if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14)) {
return adodb_date($this->fmtTimeStamp,$ts);
return date($this->fmtTimeStamp,$ts);
}

if ($ts === 'null') {
Expand All @@ -3448,7 +3448,7 @@ function DBTimeStamp($ts,$isfld=false) {
return "'$ts'";
}
$ts = ADOConnection::UnixTimeStamp($ts);
return adodb_date($this->fmtTimeStamp,$ts);
return date($this->fmtTimeStamp,$ts);
}

/**
Expand All @@ -3461,7 +3461,7 @@ static function UnixDate($v) {
if (is_object($v)) {
// odbtp support
//( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )
return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
return mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
}

if (is_numeric($v) && strlen($v) !== 8) {
Expand All @@ -3476,7 +3476,7 @@ static function UnixDate($v) {
}

// h-m-s-MM-DD-YY
return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
return mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
}


Expand All @@ -3490,7 +3490,7 @@ static function UnixTimeStamp($v) {
if (is_object($v)) {
// odbtp support
//( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )
return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
return mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
}

if (!preg_match(
Expand All @@ -3503,9 +3503,9 @@ static function UnixTimeStamp($v) {

// h-m-s-MM-DD-YY
if (!isset($rr[5])) {
return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
return mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
}
return @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
return mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
}

/**
Expand All @@ -3531,8 +3531,7 @@ function UserDate($v,$fmt='Y-m-d',$gmt=false) {
// pre-TIMESTAMP_FIRST_YEAR
}

return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);

return ($gmt) ? gmdate($fmt,$tt) : date($fmt,$tt);
}

/**
Expand All @@ -3550,7 +3549,7 @@ function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false) {
}
# strlen(14) allows YYYYMMDDHHMMSS format
if (is_numeric($v) && strlen($v)<14) {
return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v);
return ($gmt) ? gmdate($fmt,$v) : date($fmt,$v);
}
$tt = $this->UnixTimeStamp($v);
// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
Expand All @@ -3560,7 +3559,7 @@ function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false) {
if ($tt == 0) {
return $this->emptyTimeStamp;
}
return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);
return ($gmt) ? gmdate($fmt,$tt) : date($fmt,$tt);
}

/**
Expand Down Expand Up @@ -4527,7 +4526,7 @@ function getAssoc($force_array = false, $first2cols = false)
*/
function UserTimeStamp($v,$fmt='Y-m-d H:i:s') {
if (is_numeric($v) && strlen($v)<14) {
return adodb_date($fmt,$v);
return date($fmt,$v);
}
$tt = $this->UnixTimeStamp($v);
// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
Expand All @@ -4537,7 +4536,7 @@ function UserTimeStamp($v,$fmt='Y-m-d H:i:s') {
if ($tt === 0) {
return $this->emptyTimeStamp;
}
return adodb_date($fmt,$tt);
return date($fmt,$tt);
}


Expand All @@ -4557,7 +4556,7 @@ function UserDate($v,$fmt='Y-m-d') {
} else if ($tt == -1) {
// pre-TIMESTAMP_FIRST_YEAR
}
return adodb_date($fmt,$tt);
return date($fmt,$tt);
}


Expand Down
6 changes: 3 additions & 3 deletions drivers/adodb-ado.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ function _fetch()
$val=(float) variant_cast($f->value,VT_R8)*3600*24-2209161600;
else
$val = $f->value;
$this->fields[] = adodb_date('Y-m-d H:i:s',$val);
$this->fields[] = date('Y-m-d H:i:s',$val);
}
break;
case 133:// A date value (yyyymmdd)
Expand All @@ -589,8 +589,8 @@ function _fetch()
if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value);
else $val = $f->value;

if (($val % 86400) == 0) $this->fields[] = adodb_date('Y-m-d',$val);
else $this->fields[] = adodb_date('Y-m-d H:i:s',$val);
if (($val % 86400) == 0) $this->fields[] = date('Y-m-d',$val);
else $this->fields[] = date('Y-m-d H:i:s',$val);
}
break;
case 1: // null
Expand Down
6 changes: 3 additions & 3 deletions drivers/adodb-ado5.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function _fetch()
$val= (float) variant_cast($f->value,VT_R8)*3600*24-2209161600;
else
$val = $f->value;
$this->fields[] = adodb_date('Y-m-d H:i:s',$val);
$this->fields[] = date('Y-m-d H:i:s',$val);
}
break;
case 133:// A date value (yyyymmdd)
Expand All @@ -636,8 +636,8 @@ function _fetch()
if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value);
else $val = $f->value;

if (($val % 86400) == 0) $this->fields[] = adodb_date('Y-m-d',$val);
else $this->fields[] = adodb_date('Y-m-d H:i:s',$val);
if (($val % 86400) == 0) $this->fields[] = date('Y-m-d',$val);
else $this->fields[] = date('Y-m-d H:i:s',$val);
}
break;
case 1: // null
Expand Down
2 changes: 1 addition & 1 deletion drivers/adodb-db2.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ function dbTimeStamp($ts,$isField=false)
{
if (empty($ts) && $ts !== 0) return 'null';
if (is_string($ts)) $ts = ADORecordSet::unixTimeStamp($ts);
return 'TO_DATE('.adodb_date($this->fmtTimeStamp,$ts).",'YYYY-MM-DD HH24:MI:SS')";
return 'TO_DATE('.date($this->fmtTimeStamp,$ts).",'YYYY-MM-DD HH24:MI:SS')";
}

/**
Expand Down
4 changes: 2 additions & 2 deletions drivers/adodb-oci8.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ function DBDate($d,$isfld=false)
$ds = $d->format($this->fmtDate);
}
else {
$ds = adodb_date($this->fmtDate,$d);
$ds = date($this->fmtDate,$d);
}

return "TO_DATE(".$ds.",'".$this->dateformat."')";
Expand Down Expand Up @@ -425,7 +425,7 @@ function BindTimeStamp($ts)
$tss = $ts->format("'Y-m-d H:i:s'");
}
else {
$tss = adodb_date("'Y-m-d H:i:s'",$ts);
$tss = date("'Y-m-d H:i:s'",$ts);
}

return $tss;
Expand Down
4 changes: 2 additions & 2 deletions drivers/adodb-odbtp.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function DBDate($d,$isfld=false)
if ($isfld) return "convert(date, $d, 120)";

if (is_string($d)) $d = ADORecordSet::UnixDate($d);
$d = adodb_date($this->fmtDate,$d);
$d = date($this->fmtDate,$d);
return "convert(date, $d, 120)";
}

Expand All @@ -91,7 +91,7 @@ function DBTimeStamp($d,$isfld=false)
if ($isfld) return "convert(datetime, $d, 120)";

if (is_string($d)) $d = ADORecordSet::UnixDate($d);
$d = adodb_date($this->fmtDate,$d);
$d = date($this->fmtDate,$d);
return "convert(datetime, $d, 120)";
}
*/
Expand Down
4 changes: 2 additions & 2 deletions drivers/adodb-oracle.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function DBDate($d, $isfld = false)
{
if (is_string($d)) $d = ADORecordSet::UnixDate($d);
if (is_object($d)) $ds = $d->format($this->fmtDate);
else $ds = adodb_date($this->fmtDate,$d);
else $ds = date($this->fmtDate,$d);
return 'TO_DATE('.$ds.",'YYYY-MM-DD')";
}

Expand All @@ -51,7 +51,7 @@ function DBTimeStamp($ts, $isfld = false)

if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts);
if (is_object($ts)) $ds = $ts->format($this->fmtDate);
else $ds = adodb_date($this->fmtTimeStamp,$ts);
else $ds = date($this->fmtTimeStamp,$ts);
return 'TO_DATE('.$ds.",'RRRR-MM-DD, HH:MI:SS AM')";
}

Expand Down
8 changes: 3 additions & 5 deletions drivers/adodb-sqlite.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class ADODB_sqlite extends ADOConnection {
var $hasInsertID = true; /// supports autoincrement ID?
var $hasAffectedRows = true; /// supports affected rows for update/delete?
var $metaTablesSQL = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name";
var $sysDate = "adodb_date('Y-m-d')";
var $sysTimeStamp = "adodb_date('Y-m-d H:i:s')";
var $sysDate = "date('Y-m-d')";
var $sysTimeStamp = "date('Y-m-d H:i:s')";
var $fmtTimeStamp = "'Y-m-d H:i:s'";

function ServerInfo()
Expand Down Expand Up @@ -164,14 +164,12 @@ function ErrorNo()
function SQLDate($fmt, $col=false)
{
$fmt = $this->qstr($fmt);
return ($col) ? "adodb_date2($fmt,$col)" : "adodb_date($fmt)";
return ($col) ? "strftime($fmt,$col)" : "strftime($fmt)";
}


function _createFunctions()
{
@sqlite_create_function($this->_connectionID, 'adodb_date', 'adodb_date', 1);
@sqlite_create_function($this->_connectionID, 'adodb_date2', 'adodb_date2', 2);
}


Expand Down
4 changes: 1 addition & 3 deletions drivers/adodb-sqlite3.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,11 @@ function SQLDate($fmt, $col=false)
$fmt = str_replace($fromChars,$toChars,$fmt);

$fmt = $this->qstr($fmt);
return ($col) ? "adodb_date2($fmt,$col)" : "adodb_date($fmt)";
return ($col) ? "strftime($fmt,$col)" : "strftime($fmt)";
}

function _createFunctions()
{
$this->_connectionID->createFunction('adodb_date', 'adodb_date', 1);
$this->_connectionID->createFunction('adodb_date2', 'adodb_date2', 2);
}

/** @noinspection PhpUnusedParameterInspection */
Expand Down
4 changes: 2 additions & 2 deletions drivers/adodb-sybase.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ static function UnixDate($v)
$themth = $ADODB_sybase_mths[$themth];
if ($themth <= 0) return false;
// h-m-s-MM-DD-YY
return adodb_mktime(0,0,0,$themth,$rr[2],$rr[3]);
return mktime(0,0,0,$themth,$rr[2],$rr[3]);
}

static function UnixTimeStamp($v)
Expand All @@ -435,6 +435,6 @@ static function UnixTimeStamp($v)
break;
}
// h-m-s-MM-DD-YY
return adodb_mktime($rr[4],$rr[5],0,$themth,$rr[2],$rr[3]);
return mktime($rr[4],$rr[5],0,$themth,$rr[2],$rr[3]);
}
}