Add PHP_CodeSniffer, lint code
This commit is contained in:
parent
172131e1e6
commit
ddf235a61b
8 changed files with 188 additions and 68 deletions
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
if (!function_exists('render_date_difference')) {
|
||||
function render_date_difference ($start_time) {
|
||||
function render_date_difference($start_time)
|
||||
{
|
||||
$minute = 60;
|
||||
$hour = $minute * 60;
|
||||
$day = $hour * 24;
|
||||
|
@ -19,19 +20,19 @@ if (!function_exists('render_date_difference')) {
|
|||
|
||||
if ($trip_start_difference < $minute) {
|
||||
$unit = 'second';
|
||||
} else if ($trip_start_difference < $hour) {
|
||||
} elseif ($trip_start_difference < $hour) {
|
||||
$div = $minute;
|
||||
$unit = 'minute';
|
||||
} else if ($trip_start_difference < $day) {
|
||||
} elseif ($trip_start_difference < $day) {
|
||||
$div = $hour;
|
||||
$unit = 'hour';
|
||||
} else if ($trip_start_difference < $week) {
|
||||
} elseif ($trip_start_difference < $week) {
|
||||
$div = $day;
|
||||
$unit = 'day';
|
||||
} else if ($trip_start_difference < $month) {
|
||||
} elseif ($trip_start_difference < $month) {
|
||||
$div = $week;
|
||||
$unit = 'week';
|
||||
} else if ($trip_start_difference < $year) {
|
||||
} elseif ($trip_start_difference < $year) {
|
||||
$div = $month;
|
||||
$unit = 'month';
|
||||
} else {
|
||||
|
@ -39,6 +40,14 @@ if (!function_exists('render_date_difference')) {
|
|||
$unit = 'year';
|
||||
}
|
||||
|
||||
return "{$start_tag}" . ( floor ( $trip_start_difference / $div ) ) . " {$unit}" . ( ( floor ( $trip_start_difference / $div ) > 1 ) ? 's' : '' ) . " ago{$end_tag}";
|
||||
return $start_tag .
|
||||
( floor($trip_start_difference / $div) ) .
|
||||
" {$unit}" .
|
||||
(
|
||||
( floor($trip_start_difference / $div) > 1 ) ?
|
||||
's' :
|
||||
''
|
||||
) .
|
||||
" ago{$end_tag}";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue