3 * @copyright Copyright (C) 2020, Friendica
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 public static function post(array $parameters = [])
34 $time = ($_REQUEST['time'] ?? '') ?: 'now';
36 $bd_format = DI::l10n()->t('l F d, Y \@ g:i A');
38 if (!empty($_POST['timezone'])) {
39 DI::app()->data['mod-localtime'] = DateTimeFormat::convert($time, $_POST['timezone'], 'UTC', $bd_format);
43 public static function content(array $parameters = [])
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($app->data['mod-localtime'])) {
58 $output .= '<p>' . DI::l10n()->t('Converted localtime: %s', $app->data['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>';