aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-03-18 14:55:01 +0100
committerMario <mario@mariovavti.com>2021-03-18 14:55:01 +0100
commit3ba42d3dcf252cd2c07f2f1b9c0b7d54cce759c9 (patch)
tree36358bdc3b8d408e8444743d71459c9d397c4d0b
parent9f26b7aa9c6e3ba50de5a0780c917cabad7367f6 (diff)
downloadvolse-hubzilla-3ba42d3dcf252cd2c07f2f1b9c0b7d54cce759c9.tar.gz
volse-hubzilla-3ba42d3dcf252cd2c07f2f1b9c0b7d54cce759c9.tar.bz2
volse-hubzilla-3ba42d3dcf252cd2c07f2f1b9c0b7d54cce759c9.zip
air: deal with timezones when displaying open/close time - this should finally fix issue #1544
-rw-r--r--Zotlabs/Module/Register.php6
-rw-r--r--include/account.php17
-rw-r--r--include/security.php10
-rw-r--r--view/tpl/plain.tpl3
-rw-r--r--view/tpl/register.tpl7
5 files changed, 27 insertions, 16 deletions
diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php
index c8cb78e74..e98a61a5e 100644
--- a/Zotlabs/Module/Register.php
+++ b/Zotlabs/Module/Register.php
@@ -320,7 +320,7 @@ class Register extends Controller {
$reonar['from'] = get_config('system', 'from_email');
$reonar['to'] = $email;
$reonar['subject'] = sprintf( t('Registration confirmation for %s'), get_config('system','sitename'));
- $reonar['txtpersonal']= t('Valid from') . ' <span class="register_date">' . $regdelay . '</span> ' . t('and expire') . ' <span class="register_date">' . $regexpire . '</span>';
+ $reonar['txtpersonal']= t('Valid from') . ' <span data-utc="' . $regdelay . '" class="register_date">' . $regdelay . '</span> ' . t('and expire') . ' <span data-utc="' . $regexpire . '" class="register_date">' . $regexpire . '</span>';
$reonar['txttemplate']= replace_macros(get_intltext_template('register_verify_member.tpl'),
[
'$sitename' => get_config('system','sitename'),
@@ -391,7 +391,7 @@ class Register extends Controller {
$_SESSION['zar']['msg'] = ( 'ZAR0239I,' . t( 'Your digital id is' ) . EOL . 'd' . $didnew . EOL
. t('and your pin for is') . ' ' . $pass2 . EOL
. t('Keep these infos and your entered password safe') . EOL
- . t('Valid from') . ' <span class="register_date">' . datetime_convert('UTC', 'UTC', $regdelay, 'c') . '</span> ' . t('and expire') . ' <span class="register_date">' . datetime_convert('UTC', 'UTC', $regexpire, 'c') . '</span>' . EOL );
+ . t('Valid from') . ' <span data-utc="' . datetime_convert('UTC', 'UTC', $regdelay, 'c') . '" class="register_date">' . datetime_convert('UTC', 'UTC', $regdelay, 'c') . '</span> ' . t('and expire') . ' <span data-utc="' . datetime_convert('UTC', 'UTC', $regexpire, 'c') . '" class="register_date">' . datetime_convert('UTC', 'UTC', $regexpire, 'c') . '</span>' . EOL );
// acpin verify
// goaway(z_root() . '/regate/' . bin2hex('d' . $didnew) . 'a' );
@@ -545,7 +545,7 @@ class Register extends Controller {
'$pass1' => $password,
'$pass2' => $password2,
'$submit' => t('Register'),
- '$verify_note' => (($email_verify) ? t('This site requires verification. After completing this form, please check the notice or your email for further instructions.') . '<sup>ZAR0135I</sup>' : ''),
+ '$verify_note' => (($email_verify) ? t('This site requires verification. After completing this form, please check the notice or your email for further instructions.') . '<sup>ZAR0135I</sup>' : '')
));
return $o;
diff --git a/include/account.php b/include/account.php
index a6067a802..c3c7d26b7 100644
--- a/include/account.php
+++ b/include/account.php
@@ -1238,18 +1238,23 @@ function zar_register_dutystate( $now=NULL, $day=NULL ) {
$dutyis = $isduty ? t('open') : t('closed');
$atform = $isduty ? '' : 'disabled';
+ $utc_now = datetime_convert(date_default_timezone_get(), 'UTC', $now, 'c');
$nowfmt = t('Registration is currently')
- . ' ('.substr($now,0,2) . ':' . substr($now,-2) . ') '
- . ' ' . $dutyis;
+ . ' (<span data-utc="' . $utc_now . '" class="register_date">' . $utc_now . '</span>) '
+ . $dutyis . '.<br>';
+
if (!$isduty) {
$pernext = zarIsDuty($day, $now, 'nextOpen');
+ $week_days = ['','monday','tuesday','wednesday','thursday','friday','saturday','sunday'];
+ $utc_next_open = datetime_convert(date_default_timezone_get(), 'UTC', $week_days[$pernext[0]] . ' ' . $pernext[1], 'c');
+
+ if (is_array($pernext)) {
+ $nowfmt .= t('Next opens') . ' '
+ . '<span data-utc="' . $utc_next_open . '" class="register_date">' . $utc_next_open . '</span>.';
- if (is_array($pernext))
- $nowfmt .= '. ' . t('Next opens') . ' '
- . ucfirst( array('','mo','tu','we','th','fr','sa','so')[$pernext[0]]) . ' '
- . substr($pernext[1],0,2) . ':' . substr($pernext[1],-2);
+ }
}
return array( 'isduty' => $isduty, 'nowfmt' => $nowfmt, 'atform' => $atform);
diff --git a/include/security.php b/include/security.php
index 18107d5cb..4643de105 100644
--- a/include/security.php
+++ b/include/security.php
@@ -850,7 +850,7 @@ function zarIsDuty($wd=NULL, $hhmm=NULL, $op='isOpen') {
$isduty = get_config('system', 'register_duty_jso');
- if (!$isduty)
+ if (!$isduty)
return (bool)false;
is_null($wd) ? $wd = date('N') : '';
@@ -863,7 +863,7 @@ function zarIsDuty($wd=NULL, $hhmm=NULL, $op='isOpen') {
$wd === 0 ? $wd = 7 : '';
$duty = json_decode($isduty, true);
- if (!$duty)
+ if (!$duty)
return (bool)false;
switch ($op) {
@@ -883,7 +883,7 @@ function zarIsDuty($wd=NULL, $hhmm=NULL, $op='isOpen') {
}
return $dutyis;
break;
-
+
case 'nextOpen':
/**
* Look for next period opens
@@ -923,7 +923,7 @@ function zarIsDuty($wd=NULL, $hhmm=NULL, $op='isOpen') {
if ($dd >= $myd && $dh >= $myh && !$tf)
return array($dd, $dh);
else
- continue;
+ continue;
}
}
return $is1; // false or array
@@ -933,7 +933,7 @@ function zarIsDuty($wd=NULL, $hhmm=NULL, $op='isOpen') {
//
break;
}
-
+
}
diff --git a/view/tpl/plain.tpl b/view/tpl/plain.tpl
index b01ee9baa..b0c7b3081 100644
--- a/view/tpl/plain.tpl
+++ b/view/tpl/plain.tpl
@@ -3,8 +3,7 @@
<div style="font-weight: normal; font-family: monospace;">{{$infos}}</div>
<script>
$('.register_date').each( function () {
- var UTC = $(this).html();
- var date = new Date(UTC);
+ var date = new Date($(this).data('utc'));
$(this).html(date.toLocaleString());
});
</script>
diff --git a/view/tpl/register.tpl b/view/tpl/register.tpl
index c380b5c87..8033d0a76 100644
--- a/view/tpl/register.tpl
+++ b/view/tpl/register.tpl
@@ -74,5 +74,12 @@
' .zuiqmid { font-weight: normal; font-family: monospace; }'+
' .zuirise { font-weight: bold; font-size: 100%; color: red; }'+
'</style>');
+
{{$tao}}
+
+ var week_days = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'];
+ $('.register_date').each( function () {
+ var date = new Date($(this).data('utc'));
+ $(this).html(date.toLocaleString(undefined, {weekday: 'short', hour: 'numeric', minute: 'numeric'}));
+ });
</script>