diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-11-13 09:16:43 +0400 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-11-13 09:17:14 +0400 |
commit | 0e0944394715a07594f8db4845975b1a2a066709 (patch) | |
tree | 97ee9960ff1909a086350cc7de6ce7c5cf06103c /lib | |
parent | dc00a615a0bb08cd0ace782dfc07e4044bd3910d (diff) |
News: handle case where date is not specified in item (see issue #67)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils.php | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/utils.php b/lib/utils.php index 97c55ffaf..298639675 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -24,7 +24,11 @@ class Utils { * @returns */ public static function unixtimeToDbtimestamp($unixtime) { + if ($unixtime === null) + return null; $dt = \DateTime::createFromFormat('U', $unixtime); + if ($dt === false) + return null; return $dt->format('Y-m-d H:i:s'); } @@ -34,7 +38,11 @@ class Utils { * @returns */ public static function dbtimestampToUnixtime($dbtimestamp) { + if ($dbtimestamp === null) + return null; $dt = \DateTime::createFromFormat('Y-m-d H:i:s', $dbtimestamp); + if ($dt === false) + return null; return $dt->format('U'); } |