Issue #86 - Added relative time on manage outage tables.

This commit is contained in:
Daniel Thee Roperto
2016-12-14 12:29:27 +11:00
parent 9ddc1cd32c
commit b8aa1dd233
4 changed files with 14 additions and 3 deletions

View File

@@ -48,6 +48,14 @@ class base_table extends flexible_table {
*/
private static $autoid = 0;
protected static function create_starttime_string($starttime) {
$absolute = userdate($starttime, get_string('datetimeformat', 'auth_outage'));
$relative = $starttime - time();
$format = ($relative < 0) ? 'tablestarttimepastformat' : 'tablestarttimefutureformat';
$relative = format_time($relative);
return get_string($format, 'auth_outage', compact('absolute', 'relative'));
}
/**
* Constructor
* @param string|null $id to be used by the table, autogenerated if null.

View File

@@ -50,7 +50,7 @@ class history_table extends base_table {
$this->define_headers([
get_string('tableheaderwarnbefore', 'auth_outage'),
get_string('tableheaderstarttime', 'auth_outage'),
get_string('tableheaderstartedtime', 'auth_outage'),
get_string('tableheaderdurationplanned', 'auth_outage'),
get_string('tableheaderdurationactual', 'auth_outage'),
get_string('tableheadertitle', 'auth_outage'),
@@ -71,7 +71,7 @@ class history_table extends base_table {
$finished = is_null($finished) ? '-' : format_time($finished);
$this->add_data([
format_time($outage->get_warning_duration()),
userdate($outage->starttime, get_string('datetimeformat', 'auth_outage')),
self::create_starttime_string($outage->starttime),
format_time($outage->get_duration_planned()),
$finished,
$outage->get_title(),

View File

@@ -75,7 +75,7 @@ class planned_table extends base_table {
$this->add_data([
format_time($outage->get_warning_duration()),
userdate($outage->starttime, get_string('datetimeformat', 'auth_outage')),
self::create_starttime_string($outage->starttime),
format_time($outage->get_duration_planned()),
$title,
$this->create_data_buttons($outage, true),