From d53c3d7075763e5f95df4eca27a76d431c9c791f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 May 2015 10:10:23 +0200 Subject: [PATCH] Add view helper functions for formatting, date, date and time, and time refs #6778 --- library/Icinga/Web/View/helpers/format.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/library/Icinga/Web/View/helpers/format.php b/library/Icinga/Web/View/helpers/format.php index 33aeb86a1..115f13424 100644 --- a/library/Icinga/Web/View/helpers/format.php +++ b/library/Icinga/Web/View/helpers/format.php @@ -10,6 +10,27 @@ $this->addHelperFunction('format', function () { return Format::getInstance(); }); +$this->addHelperFunction('formatDate', function ($date) { + if (! $date) { + return ''; + } + return DateFormatter::formatDate($date); +}); + +$this->addHelperFunction('formatDateTime', function ($dateTime) { + if (! $dateTime) { + return ''; + } + return DateFormatter::formatDateTime($dateTime); +}); + +$this->addHelperFunction('formatTime', function ($time) { + if (! $time) { + return ''; + } + return DateFormatter::formatTime($time); +}); + $this->addHelperFunction('timeAgo', function ($time, $timeOnly = false) { if (! $time) { return '';