mirror of
				https://github.com/Icinga/icingaweb2.git
				synced 2025-10-31 19:34:16 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Icinga\Web\View;
 | |
| 
 | |
| use Icinga\Web\Url;
 | |
| use Icinga\Util\Format;
 | |
| 
 | |
| $this->addHelperFunction('format', function () {
 | |
|     return Format::getInstance();
 | |
| });
 | |
| 
 | |
| $this->addHelperFunction('timeSince', function ($timestamp) {
 | |
|     return sprintf(
 | |
|         '<span class="timeuntil" title="%s">%s</span>',
 | |
|         date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
 | |
|         Format::timeSince($timestamp)
 | |
|     );
 | |
| });
 | |
| 
 | |
| $this->addHelperFunction('prefixedTimeSince', function ($timestamp, $ucfirst = false) {
 | |
|     return sprintf(
 | |
|         '<span class="timeuntil" title="%s">%s</span>',
 | |
|         date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
 | |
|         Format::prefixedTimeSince($timestamp, $ucfirst)
 | |
|     );
 | |
| });
 | |
| 
 | |
| $this->addHelperFunction('timeUntil', function ($timestamp) {
 | |
|     if (! $timestamp) return '';
 | |
|     return sprintf(
 | |
|         '<span class="timeuntil" title="%s">%s</span>',
 | |
|         date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
 | |
|         Format::timeUntil($timestamp)
 | |
|     );
 | |
| });
 | |
| 
 | |
| $this->addHelperFunction('prefixedTimeUntil', function ($timestamp, $ucfirst = false) {
 | |
|     if (! $timestamp) return '';
 | |
|     return sprintf(
 | |
|         '<span class="timeuntil" title="%s">%s</span>',
 | |
|         date('Y-m-d H:i:s', $timestamp), // TODO: internationalized format
 | |
|         Format::prefixedTimeUntil($timestamp, $ucfirst)
 | |
|     );
 | |
| });
 |