aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2014-01-29 20:50:58 +0000
committermistic100 <mistic@piwigo.org>2014-01-29 20:50:58 +0000
commit7de2f7cf7351c2420d0774d7a19537e061713dd0 (patch)
tree3dfa2c6755b71ad86e4ccc99d01602bb8c8af7eb /include/functions.inc.php
parent6fcc5f10df0fbd02877e49aec7b662c64c60acc7 (diff)
Merged revision(s) 27043 from trunk:
str2DateTime return false on empty input git-svn-id: http://piwigo.org/svn/branches/2.6@27044 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions.inc.php')
-rw-r--r--include/functions.inc.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 1e2b1486f..a08bd94b4 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -544,7 +544,12 @@ function dateDiff($date1, $date2)
*/
function str2DateTime($original, $format=null)
{
- if ( !empty($format) && version_compare(PHP_VERSION, '5.3.0') >= 0 )// from known date format
+ if (empty($original))
+ {
+ return false;
+ }
+
+ if (!empty($format) && version_compare(PHP_VERSION, '5.3.0') >= 0)// from known date format
{
return DateTime::createFromFormat('!'.$format, $original); // ! char to reset fields to UNIX epoch
}
@@ -553,7 +558,7 @@ function str2DateTime($original, $format=null)
$t = trim($original, '0123456789');
if (empty($t)) // from timestamp
{
- $date = new DateTime('@'.$original);
+ return new DateTime('@'.$original);
}
else // from unknown date format (assuming something like Y-m-d H:i:s)
{
@@ -573,9 +578,8 @@ function str2DateTime($original, $format=null)
$date = new DateTime();
$date->setDate($ymdhms[0], $ymdhms[1], $ymdhms[2]);
$date->setTime($ymdhms[3], $ymdhms[4], $ymdhms[5]);
+ return $date;
}
-
- return $date;
}
}