]> git.mxchange.org Git - friendica.git/blob - src/Module/Debug/Localtime.php
Merge pull request #11503 from annando/bulk-delivery
[friendica.git] / src / Module / Debug / Localtime.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Module\Debug;
23
24 use Friendica\BaseModule;
25 use Friendica\Core\Installer;
26 use Friendica\DI;
27 use Friendica\Util\DateTimeFormat;
28 use Friendica\Util\Temporal;
29
30 class Localtime extends BaseModule
31 {
32         static $mod_localtime = '';
33
34         protected function post(array $request = [])
35         {
36                 $time = ($_REQUEST['time'] ?? '') ?: 'now';
37
38                 $bd_format = DI::l10n()->t('l F d, Y \@ g:i A');
39
40                 if (!empty($_POST['timezone'])) {
41                         self::$mod_localtime = DateTimeFormat::convert($time, $_POST['timezone'], 'UTC', $bd_format);
42                 }
43         }
44
45         protected function content(array $request = []): string
46         {
47                 $time = ($_REQUEST['time'] ?? '') ?: 'now';
48
49                 $output  = '<h3>' . DI::l10n()->t('Time Conversion') . '</h3>';
50                 $output .= '<p>' . DI::l10n()->t('Friendica provides this service for sharing events with other networks and friends in unknown timezones.') . '</p>';
51                 $output .= '<p>' . DI::l10n()->t('UTC time: %s', $time) . '</p>';
52
53                 if (!empty($_REQUEST['timezone'])) {
54                         $output .= '<p>' . DI::l10n()->t('Current timezone: %s', $_REQUEST['timezone']) . '</p>';
55                 }
56
57                 if (!empty(self::$mod_localtime)) {
58                         $output .= '<p>' . DI::l10n()->t('Converted localtime: %s', self::$mod_localtime) . '</p>';
59                 }
60
61                 $output .= '<form action ="' . DI::baseUrl()->get() . '/localtime?time=' . $time . '" method="post" >';
62                 $output .= '<p>' . DI::l10n()->t('Please select your timezone:') . '</p>';
63                 $output .= Temporal::getTimezoneSelect(($_REQUEST['timezone'] ?? '') ?: Installer::DEFAULT_TZ);
64                 $output .= '<input type="submit" name="submit" value="' . DI::l10n()->t('Submit') . '" /></form>';
65
66                 return $output;
67         }
68 }