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