aboutsummaryrefslogtreecommitdiffstats
path: root/include/datetime.php
diff options
context:
space:
mode:
authorfabrixxm <fabrix.xm@gmail.com>2011-07-05 07:11:57 +0200
committerfabrixxm <fabrix.xm@gmail.com>2011-07-05 07:11:57 +0200
commit4e7a5dc56ebb8d99ed06b0b303c4ee24460ae6a8 (patch)
tree84184bd3aa80c896b8dceaf5a017297c7267f2cb /include/datetime.php
parentcfd59f6ac8848c19a0c451c378d2b770cafcbef0 (diff)
parent2359783b9f6c0ec754c641453026712cf22e7cb6 (diff)
downloadvolse-hubzilla-4e7a5dc56ebb8d99ed06b0b303c4ee24460ae6a8.tar.gz
volse-hubzilla-4e7a5dc56ebb8d99ed06b0b303c4ee24460ae6a8.tar.bz2
volse-hubzilla-4e7a5dc56ebb8d99ed06b0b303c4ee24460ae6a8.zip
Merge branch 'dispy' of github.com:fabrixxm/friendika into dispy
Diffstat (limited to 'include/datetime.php')
-rw-r--r--include/datetime.php21
1 files changed, 13 insertions, 8 deletions
diff --git a/include/datetime.php b/include/datetime.php
index a5b388e76..a056eaa60 100644
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -65,9 +65,9 @@ if(! function_exists('datetime_convert')) {
function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d H:i:s") {
// Slight hackish adjustment so that 'zero' datetime actually returns what is intended
- // otherwise we end up with -0001-11-30 ...
+ // 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.
+ // months and days always start with 1.
if(substr($s,0,10) == '0000-00-00') {
$d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
@@ -176,6 +176,11 @@ function relative_date($posted_date) {
$localtime = datetime_convert('UTC',date_default_timezone_get(),$posted_date);
$abs = strtotime($localtime);
+
+ if (is_null($posted_date) || $posted_date === '0000-00-00 00:00:00' || $abs === False) {
+ return t('never');
+ }
+
$etime = time() - $abs;
if ($etime < 1) {
@@ -183,12 +188,12 @@ function relative_date($posted_date) {
}
$a = array( 12 * 30 * 24 * 60 * 60 => array( t('year'), t('years')),
- 30 * 24 * 60 * 60 => array( t('month'), t('months')),
- 7 * 24 * 60 * 60 => array( t('week'), t('weeks')),
- 24 * 60 * 60 => array( t('day'), t('days')),
- 60 * 60 => array( t('hour'), t('hours')),
- 60 => array( t('minute'), t('minutes')),
- 1 => array( t('second'), t('seconds'))
+ 30 * 24 * 60 * 60 => array( t('month'), t('months')),
+ 7 * 24 * 60 * 60 => array( t('week'), t('weeks')),
+ 24 * 60 * 60 => array( t('day'), t('days')),
+ 60 * 60 => array( t('hour'), t('hours')),
+ 60 => array( t('minute'), t('minutes')),
+ 1 => array( t('second'), t('seconds'))
);
foreach ($a as $secs => $str) {