3 namespace Friendica\Module\Debug;
5 use Friendica\BaseModule;
6 use Friendica\Core\Installer;
7 use Friendica\Core\L10n;
8 use Friendica\Util\DateTimeFormat;
9 use Friendica\Util\Temporal;
11 class Localtime extends BaseModule
13 public static function post(array $parameters = [])
15 $time = ($_REQUEST['time'] ?? '') ?: 'now';
17 $bd_format = L10n::t('l F d, Y \@ g:i A');
19 if (!empty($_POST['timezone'])) {
20 self::getApp()->data['mod-localtime'] = DateTimeFormat::convert($time, $_POST['timezone'], 'UTC', $bd_format);
24 public static function content(array $parameters = [])
26 $app = self::getApp();
28 $time = ($_REQUEST['time'] ?? '') ?: 'now';
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>';
34 if (!empty($_REQUEST['timezone'])) {
35 $output .= '<p>' . L10n::t('Current timezone: %s', $_REQUEST['timezone']) . '</p>';
38 if (!empty($app->data['mod-localtime'])) {
39 $output .= '<p>' . L10n::t('Converted localtime: %s', $app->data['mod-localtime']) . '</p>';
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>';