summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlessandro Cosentino <cosenal@gmail.com>2012-11-13 15:38:54 -0500
committerAlessandro Cosentino <cosenal@gmail.com>2012-11-13 15:38:54 -0500
commit7c5d3649a3f137cc4c4bdd36dbb3639f2638d52c (patch)
treeba7bc9255f90db3f4cc2f2fb0f3a26190b55ffd1 /lib
parent24c3d0c92e954cbe76c1742f4155f8488caa1ad1 (diff)
use the core functions for relative dates
Diffstat (limited to 'lib')
-rw-r--r--lib/utils.php20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/utils.php b/lib/utils.php
index 298639675..aa1111dec 100644
--- a/lib/utils.php
+++ b/lib/utils.php
@@ -20,29 +20,33 @@ class Utils {
/**
* @brief Transform a date from UNIX timestamp format to MDB2 timestamp format
- * @param dbtimestamp
- * @returns
+ * @param dbtimestamp a date in the UNIX timestamp format
+ * @returns a date in the MDB2 timestamp format, or NULL if an error occurred
*/
public static function unixtimeToDbtimestamp($unixtime) {
- if ($unixtime === null)
+ if ($unixtime === null) {
return null;
+ }
$dt = \DateTime::createFromFormat('U', $unixtime);
- if ($dt === false)
+ if ($dt === false) {
return null;
+ }
return $dt->format('Y-m-d H:i:s');
}
/**
* @brief Transform a date from MDB2 timestamp format to UNIX timestamp format
- * @param dbtimestamp
- * @returns
+ * @param dbtimestamp a date in the MDB2 timestamp format
+ * @returns a date in the UNIX timestamp format, or NULL if an error occurred
*/
public static function dbtimestampToUnixtime($dbtimestamp) {
- if ($dbtimestamp === null)
+ if ($dbtimestamp === null) {
return null;
+ }
$dt = \DateTime::createFromFormat('Y-m-d H:i:s', $dbtimestamp);
- if ($dt === false)
+ if ($dt === false) {
return null;
+ }
return $dt->format('U');
}