aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <mike@macgirvin.com>2016-09-26 18:16:43 -0700
committerredmatrix <mike@macgirvin.com>2016-09-26 18:16:43 -0700
commitcacdac16aa104eb1308f69f24fef31f682934fca (patch)
tree02be2495ad66a7950e342b075144e2fc0958d79d /include
parentfb9544badd66043bf7ee5a7566ba288ad7da29fa (diff)
downloadvolse-hubzilla-cacdac16aa104eb1308f69f24fef31f682934fca.tar.gz
volse-hubzilla-cacdac16aa104eb1308f69f24fef31f682934fca.tar.bz2
volse-hubzilla-cacdac16aa104eb1308f69f24fef31f682934fca.zip
next wave of nulldate fixes
Diffstat (limited to 'include')
-rw-r--r--include/datetime.php13
-rwxr-xr-xinclude/dba/dba_driver.php18
2 files changed, 15 insertions, 16 deletions
diff --git a/include/datetime.php b/include/datetime.php
index c72e4bf83..cd08ab367 100644
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -85,15 +85,20 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
if( ($s === '') || (! is_string($s)) )
$s = 'now';
+ if(is_null_date($s)) {
+ $d = new DateTime('0001-01-01 00:00:00', new DateTimeZone('UTC'));
+ return $d->format($fmt);
+ }
+
// Slight hackish adjustment so that 'zero' datetime actually returns what is intended
// otherwise we end up with -0001-11-30 ...
// add 32 days so that we at least get year 00, and then hack around the fact that
// months and days always start with 1.
- if(substr($s,0,10) == '0000-00-00') {
- $d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
- return str_replace('1', '0', $d->format($fmt));
- }
+// if(substr($s,0,10) == '0000-00-00') {
+// $d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
+// return str_replace('1', '0', $d->format($fmt));
+// }
try {
$from_obj = new DateTimeZone($from);
diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php
index 7225a9be2..2cbdd529d 100755
--- a/include/dba/dba_driver.php
+++ b/include/dba/dba_driver.php
@@ -86,7 +86,7 @@ class DBA {
abstract class dba_driver {
// legacy behavior
const INSTALL_SCRIPT='install/schema_mysql.sql';
- const NULL_DATE = '0000-00-00 00:00:00';
+ const NULL_DATE = '0001-01-01 00:00:00';
const UTC_NOW = 'UTC_TIMESTAMP()';
protected $db;
@@ -276,12 +276,9 @@ function dbunescbin($str) {
}
function dbescdate($date) {
- if(ACTIVE_DBTYPE == DBTYPE_POSTGRES && $date == '0000-00-00 00:00:00') {
- $date = NULL_DATE;
- } else if(ACTIVE_DBTYPE != DBTYPE_POSTGRES && $date == '0001-01-01 00:00:00') {
- $date = NULL_DATE;
- }
- return $date;
+ if(is_null_date($date))
+ return $dba->escape(NULL_DATE);
+ return $dba->escape($date);
}
function db_quoteinterval($txt) {
@@ -376,11 +373,8 @@ function dbq($sql) {
function dbesc_array_cb(&$item, $key) {
if(is_string($item)) {
- if($item == '0000-00-00 00:00:00' && ACTIVE_DBTYPE == DBTYPE_POSTGRES)
- $item = '0001-01-01 00:00:00';
- else if($item == '0001-01-01 00:00:00' && ACTIVE_DBTYPE == DBTYPE_MYSQL)
- $item = '0000-00-00 00:00:00';
-
+ if(is_null_date($item))
+ $item = NULL_DATE;
$item = dbesc($item);
}
}