Make format_date, format_time and format_datetime accept either a unix timestamp, or a text string

switch important_dates to use format_datetime
This commit is contained in:
james 2008-08-28 22:11:10 +00:00
parent c45edf34ec
commit b2fb7855f0
2 changed files with 19 additions and 5 deletions

View File

@ -1107,18 +1107,32 @@ function theme_icon($icon) {
return "";
}
//$d can be a unix timestamp integer, OR a text string, eg 2008-01-22
function format_date($d) {
global $config;
return date($config['dateformat'],strtotime($d));
if(is_numeric($d))
return date($config['dateformat'],$d);
else
return date($config['dateformat'],strtotime($d));
}
//$t can be a unix timestamp integer, or a text string, eg 10:23:48
function format_time($t) {
global $config;
return date($config['timeformat'],strtotime($t));
if(is_numeric($t))
return date($config['timeformat'],$t);
else
return date($config['timeformat'],strtotime($t));
}
//$dt can be a unix timestamp integer, or a text string, eg 2008-01-22 10:23:48
function format_datetime($dt) {
list($d,$t)=split(" ",$dt);
return format_date($d)." ".i18n("at")." ".format_time($t);
if(is_numeric($dt)) {
return format_date($dt)." ".i18n("at")." ".format_time($dt);
}
else {
list($d,$t)=split(" ",$dt);
return format_date($d)." ".i18n("at")." ".format_time($t);
}
}
?>

View File

@ -34,7 +34,7 @@
if($r->date == '0000-00-00 00:00:00')
$d = i18n("not specified");
else
$d = date($config['dateformat']." ".$config['timeformat'],$r->udate);
$d = format_datetime($r->udate);
echo "<tr class=\"$trclass\"><td>".i18n($r->description)."</td><td>$d</td></tr>";
}
echo "</table>";