-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhelper.php
More file actions
48 lines (41 loc) · 1.65 KB
/
helper.php
File metadata and controls
48 lines (41 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* @package Bears Clock
* @author N6REJ
* @email troy@hallhome.us
* @website https://www.hallhome.us
* @copyright Copyright (c) 2025 N6REJ
* @license GNU General Public License version 3 or later; see LICENSE
* @since 2025.6.8
*/
declare(strict_types=1);
namespace BearsClock\Module\BearsClock\Site\Helper;
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
use Joomla\Registry\Registry;
final class BearsClockHelper
{
public static function getTime(Registry $params): string
{
$timezone = $params->get('timezone');
date_default_timezone_set($timezone);
return date('F d, Y H:i:s');
}
public static function getOutputTimezone(Registry $params): string
{
$timezoneOut = $params->get('timezone', 'UTC');
$timezoneFormat = $params->get('timezone-format', 'full');
if ($timezoneFormat === 'full') {
$timezoneOut = str_replace('Indian/', 'Indian Ocean, ', $timezoneOut);
$timezoneOut = str_replace('Pacific/', 'Pacific Ocean, ', $timezoneOut);
$timezoneOut = str_replace('Atlantic/', 'Atlantic Ocean, ', $timezoneOut);
$timezoneOut = str_replace('/', ', ', $timezoneOut);
} elseif ($timezoneFormat === 'city') {
// Strip everything before and including the last '/'
if (strpos($timezoneOut, '/') !== false) {
$timezoneOut = substr($timezoneOut, strrpos($timezoneOut, '/') + 1);
}
}
$timezoneOut = str_replace('_', ' ', $timezoneOut);
return $timezoneOut;
}
}