-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove
gipfl/format
package dependency
refs: #2847
- Loading branch information
Showing
7 changed files
with
71 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Icinga\Module\Director\Web\Table; | ||
|
||
use DateTime; | ||
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable; | ||
use IntlDateFormatter; | ||
use Locale; | ||
|
||
abstract class IntlZfQueryBasedTable extends ZfQueryBasedTable | ||
{ | ||
protected function getDateFormatter() | ||
{ | ||
return (new IntlDateFormatter( | ||
Locale::getDefault(), | ||
IntlDateFormatter::FULL, | ||
IntlDateFormatter::NONE | ||
)); | ||
} | ||
|
||
/** | ||
* @param int $timestamp | ||
*/ | ||
protected function renderDayIfNew($timestamp) | ||
{ | ||
$day = $this->getDateFormatter()->format((new DateTime())->setTimestamp($timestamp)); | ||
|
||
if ($this->lastDay !== $day) { | ||
$this->nextHeader()->add( | ||
$this::th($day, [ | ||
'colspan' => 2, | ||
'class' => 'table-header-day' | ||
]) | ||
); | ||
|
||
$this->lastDay = $day; | ||
$this->nextBody(); | ||
} | ||
} | ||
|
||
protected function getTime(int $timeStamp) | ||
{ | ||
$timeFormatter = $this->getDateFormatter(); | ||
|
||
$timeFormatter->setPattern( | ||
in_array(Locale::getDefault(), ['en_US', 'en_US.UTF-8']) ? 'h:mm:ss a': 'H:mm:ss' | ||
); | ||
|
||
return $timeFormatter->format((new DateTime())->setTimestamp($timeStamp)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters