3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
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.
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.
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/>.
22 namespace Friendica\Module\Debug;
24 use Friendica\BaseModule;
25 use Friendica\Core\Installer;
27 use Friendica\Util\DateTimeFormat;
28 use Friendica\Util\Temporal;
30 class Localtime extends BaseModule
32 static $mod_localtime = '';
34 protected function post(array $request = [])
36 $time = ($_REQUEST['time'] ?? '') ?: 'now';
38 $bd_format = DI::l10n()->t('l F d, Y \@ g:i A');
40 if (!empty($_POST['timezone'])) {
41 self::$mod_localtime = DateTimeFormat::convert($time, $_POST['timezone'], 'UTC', $bd_format);
45 protected function content(array $request = []): string
47 $time = ($_REQUEST['time'] ?? '') ?: 'now';
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>';
53 if (!empty($_REQUEST['timezone'])) {
54 $output .= '<p>' . DI::l10n()->t('Current timezone: %s', $_REQUEST['timezone']) . '</p>';
57 if (!empty(self::$mod_localtime)) {
58 $output .= '<p>' . DI::l10n()->t('Converted localtime: %s', self::$mod_localtime) . '</p>';
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>';