From 89e2c7d7f9a9e2889770409c7d2be668c06af87d Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 16 Mar 2016 22:57:29 +0100 Subject: * TimezoneDTO comparator --- app/php/components/TimezoneSelect.php | 8 +------- app/php/dto/TimezoneDTO.php | 5 +++++ 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/php/components/TimezoneSelect.php b/app/php/components/TimezoneSelect.php index 5825b1a..50dc494 100644 --- a/app/php/components/TimezoneSelect.php +++ b/app/php/components/TimezoneSelect.php @@ -41,13 +41,7 @@ class TimezoneSelect extends TTemplateControl { }, DateTimeZone::listIdentifiers() ); - usort( - $timezones, - function($tz1, $tz2) { - $diff = $tz1->Offset - $tz2->Offset; - return ($diff == 0) ? strcmp($tz1->Name, $tz2->Name) : $diff; - } - ); + usort($timezones, ['TimezoneDTO', '__compare']); return $timezones; } diff --git a/app/php/dto/TimezoneDTO.php b/app/php/dto/TimezoneDTO.php index 4bb57f2..d80d4dd 100644 --- a/app/php/dto/TimezoneDTO.php +++ b/app/php/dto/TimezoneDTO.php @@ -17,6 +17,11 @@ class TimezoneDTO { $this->Label = sprintf('UTC%+03d:%02d %s', $this->OffsetHours, $this->OffsetMinutes, $this->Name); } + public static function __compare(TimezoneDTO $tz1, TimezoneDTO $tz2) { + $diff = $tz1->Offset - $tz2->Offset; + return ($diff == 0) ? strcmp($tz1->Name, $tz2->Name) : $diff; + } + } ?> -- cgit v1.2.3