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