]> git.mxchange.org Git - friendica.git/blob - src/Module/Debug/Localtime.php
parameters now are having a default value and are optional
[friendica.git] / src / Module / Debug / Localtime.php
1 <?php
2
3 namespace Friendica\Module\Debug;
4
5 use Friendica\BaseModule;
6 use Friendica\Core\Installer;
7 use Friendica\Core\L10n;
8 use Friendica\Util\DateTimeFormat;
9 use Friendica\Util\Temporal;
10
11 class Localtime extends BaseModule
12 {
13         public static function post(array $parameters = [])
14         {
15                 $time = ($_REQUEST['time'] ?? '') ?: 'now';
16
17                 $bd_format = L10n::t('l F d, Y \@ g:i A');
18
19                 if (!empty($_POST['timezone'])) {
20                         self::getApp()->data['mod-localtime'] = DateTimeFormat::convert($time, $_POST['timezone'], 'UTC', $bd_format);
21                 }
22         }
23
24         public static function content(array $parameters = [])
25         {
26                 $app = self::getApp();
27
28                 $time = ($_REQUEST['time'] ?? '') ?: 'now';
29
30                 $output  = '<h3>' . L10n::t('Time Conversion') . '</h3>';
31                 $output .= '<p>' . L10n::t('Friendica provides this service for sharing events with other networks and friends in unknown timezones.') . '</p>';
32                 $output .= '<p>' . L10n::t('UTC time: %s', $time) . '</p>';
33
34                 if (!empty($_REQUEST['timezone'])) {
35                         $output .= '<p>' . L10n::t('Current timezone: %s', $_REQUEST['timezone']) . '</p>';
36                 }
37
38                 if (!empty($app->data['mod-localtime'])) {
39                         $output .= '<p>' . L10n::t('Converted localtime: %s', $app->data['mod-localtime']) . '</p>';
40                 }
41
42                 $output .= '<form action ="' . $app->getBaseURL() . '/localtime?time=' . $time . '" method="post" >';
43                 $output .= '<p>' . L10n::t('Please select your timezone:') . '</p>';
44                 $output .= Temporal::getTimezoneSelect(($_REQUEST['timezone'] ?? '') ?: Installer::DEFAULT_TZ);
45                 $output .= '<input type="submit" name="submit" value="' . L10n::t('Submit') . '" /></form>';
46
47                 return $output;
48         }
49 }