]> git.mxchange.org Git - friendica.git/blob - mod/localtime.php
Ops, one more left ...
[friendica.git] / mod / localtime.php
1 <?php
2 /**
3  * @file mod/localtime.php
4  */
5
6 use Friendica\App;
7 use Friendica\Core\L10n;
8 use Friendica\Core\System;
9 use Friendica\Util\DateTimeFormat;
10 use Friendica\Util\Temporal;
11
12 function localtime_post(App $a)
13 {
14         $t = $_REQUEST['time'];
15         if (! $t) {
16                 $t = 'now';
17         }
18
19         $bd_format = L10n::t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
20
21         if ($_POST['timezone']) {
22                 $a->data['mod-localtime'] = DateTimeFormat::convert($t, $_POST['timezone'], 'UTC', $bd_format);
23         }
24 }
25
26 function localtime_content(App $a)
27 {
28         $t = $_REQUEST['time'];
29         if (! $t) {
30                 $t = 'now';
31         }
32
33         $o  = '<h3>' . L10n::t('Time Conversion') . '</h3>';
34
35         $o .= '<p>' . L10n::t('Friendica provides this service for sharing events with other networks and friends in unknown timezones.') . '</p>';
36
37
38
39         $o .= '<p>' . L10n::t('UTC time: %s', $t) . '</p>';
40
41         if ($_REQUEST['timezone']) {
42                 $o .= '<p>' . L10n::t('Current timezone: %s', $_REQUEST['timezone']) . '</p>';
43         }
44
45         if (x($a->data, 'mod-localtime')) {
46                 $o .= '<p>' . L10n::t('Converted localtime: %s', $a->data['mod-localtime']) . '</p>';
47         }
48
49
50         $o .= '<form action ="' . System::baseUrl() . '/localtime?f=&time=' . $t . '" method="post" >';
51
52         $o .= '<p>' . L10n::t('Please select your timezone:') . '</p>';
53
54         $o .= Temporal::getTimezoneSelect(($_REQUEST['timezone']) ? $_REQUEST['timezone'] : 'America/Los_Angeles');
55
56         $o .= '<input type="submit" name="submit" value="' . L10n::t('Submit') . '" /></form>';
57
58         return $o;
59 }