From: Tim Düsterhus Date: Tue, 9 Oct 2012 16:29:27 +0000 (+0200) Subject: Adding DateUtil::diff barebone X-Git-Tag: 2.0.0_Beta_1~912 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=56b9b9174577b2194a6cad5fbc23f24e2feb3361;p=GitHub%2FWoltLab%2FWCF.git Adding DateUtil::diff barebone --- diff --git a/wcfsetup/install/files/lib/system/template/plugin/DatediffModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/DatediffModifierTemplatePlugin.class.php index 289b62d6a2..1be62ee1bd 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/DatediffModifierTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/DatediffModifierTemplatePlugin.class.php @@ -27,8 +27,6 @@ class DatediffModifierTemplatePlugin implements IModifierTemplatePlugin { $start = min($tagArgs[0], $tagArgs[1]); $end = max($tagArgs[0], $tagArgs[1]); - // TODO: method doesn't exists anymore - // return DateUtil::diff($start, $end, 'string'); - return ''; + return DateUtil::diff(DateUtil::getDateTimeByTimestamp($start), DateUtil::getDateTimeByTimestamp($end)); } } diff --git a/wcfsetup/install/files/lib/util/DateUtil.class.php b/wcfsetup/install/files/lib/util/DateUtil.class.php index 2467b5bf8a..81d7c4aebd 100644 --- a/wcfsetup/install/files/lib/util/DateUtil.class.php +++ b/wcfsetup/install/files/lib/util/DateUtil.class.php @@ -300,5 +300,12 @@ final class DateUtil { } } + public static function diff(\DateTime $from, \DateTime $to) { + $interval = $from->diff($to); + + // TODO: Use language items + return $interval->format('%Y years %M months %D days %H hours %I minutes %S seconds'); + } + private function __construct() { } }