X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fdatetime.php;h=a056eaa60e34492158f09fc4bd19d29869655a17;hb=a13eaf915c70a69f877605622b249cc1c2c46621;hp=724eec9336c9c379f3c464253ba77766a044b1c5;hpb=3ad7c395fb9a33319531e04673563e7c9983d8f0;p=friendica.git diff --git a/include/datetime.php b/include/datetime.php index 724eec9336..a056eaa60e 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')); @@ -108,20 +108,28 @@ function datesel($pre,$ymin,$ymax,$allow_blank,$y,$m,$d) { $o .= ""; } - for($x = $ymax; $x >= $ymin; $x --) { - $sel = (($x == $y) ? " selected=\"selected\" " : ""); - $o .= ""; + if($ymax > $ymin) { + for($x = $ymax; $x >= $ymin; $x --) { + $sel = (($x == $y) ? " selected=\"selected\" " : ""); + $o .= ""; + } + } + else { + for($x = $ymax; $x <= $ymin; $x ++) { + $sel = (($x == $y) ? " selected=\"selected\" " : ""); + $o .= ""; + } } $o .= " "; + for($x = 0; $x < 24; $x ++) { + $sel = (($x == $h) ? " selected=\"selected\" " : ""); + $o .= ""; + } + $o .= " : "; + return $o; +}} + + + + + + + + // implements "3 seconds ago" etc. // based on $posted_date, (UTC). // Results relative to current timezone @@ -142,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) { @@ -149,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) { @@ -242,7 +281,7 @@ function get_first_dim($y,$m) { if(! function_exists('cal')) { -function cal($y = 0,$m = 0, $links = false) { +function cal($y = 0,$m = 0, $links = false, $class='') { // month table - start at 1 to match human usage. @@ -272,10 +311,10 @@ function cal($y = 0,$m = 0, $links = false) { $tddate = intval(datetime_convert('UTC',date_default_timezone_get(),'now','j')); $str_month = day_translate($mtab[$m]); - $o = ''; + $o = '
'; $o .= ""; for($a = 0; $a < 7; $a ++) - $o .= ''; + $o .= ''; $o .= ''; while($d <= $l) {
$str_month $y
' . substr(day_translate($dn[$a]),0,3) . '' . mb_substr(day_translate($dn[$a]),0,3,'UTF-8') . '