Fix code style in src/Util/Temporal

This commit is contained in:
Hypolite Petovan 2025-01-26 17:47:23 -05:00
parent f3202b0508
commit 8f0a31dc1e

View file

@ -147,7 +147,8 @@ class Temporal
}
$tpl = Renderer::getMarkupTemplate("field_input.tpl");
$o = Renderer::replaceMacros($tpl,
$o = Renderer::replaceMacros(
$tpl,
[
'$field' => [
'dob',
@ -157,7 +158,8 @@ class Temporal
'',
'placeholder="' . DI::l10n()->t('YYYY-MM-DD or MM-DD') . '"'
]
]);
]
);
return $o;
}
@ -223,17 +225,19 @@ class Temporal
bool $picktime = true,
string $minfrom = '',
string $maxfrom = '',
bool $required = false): string
{
bool $required = false
): string {
// First day of the week (0 = Sunday)
$firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week') ?: 0;
$lang = DI::l10n()->toISO6391(DI::l10n()->getCurrentLang());
// Check if the detected language is supported by the picker
if (!in_array($lang,
if (!in_array(
$lang,
['ar', 'ro', 'id', 'bg', 'fa', 'ru', 'uk', 'en', 'el', 'de', 'nl', 'tr', 'fr', 'es', 'th', 'pl', 'pt', 'ch', 'se', 'kr',
'it', 'da', 'no', 'ja', 'vi', 'sl', 'cs', 'hu'])) {
'it', 'da', 'no', 'ja', 'vi', 'sl', 'cs', 'hu']
)) {
$lang = 'en';
}
@ -329,7 +333,7 @@ class Temporal
return $compare_time ? DI::l10n()->t('less than a second ago') : DI::l10n()->t('today');
}
if ($etime < 0){
if ($etime < 0) {
$etime = -$etime;
$isfuture = true;
}
@ -349,10 +353,9 @@ class Temporal
if ($d >= 1) {
$r = floor($d);
// translators - e.g. 22 hours ago, 1 minute ago
if($isfuture){
if($isfuture) {
$format = DI::l10n()->t('in %1$d %2$s');
}
else {
} else {
$format = DI::l10n()->t('%1$d %2$s ago');
}
@ -475,7 +478,7 @@ class Temporal
$str_month = DI::l10n()->getDay($mtab[$m]);
$o = '<table class="calendar' . $class . '">';
$o .= "<caption>$str_month $y</caption><tr>";
for ($a = 0; $a < 7; $a ++) {
for ($a = 0; $a < 7; $a++) {
$o .= '<th>' . mb_substr(DI::l10n()->getDay($dn[$a]), 0, 3, 'UTF-8') . '</th>';
}
@ -496,13 +499,13 @@ class Temporal
$o .= $day;
}
$d ++;
$d++;
} else {
$o .= '&nbsp;';
}
$o .= '</td>';
$dow ++;
$dow++;
if (($dow == 7) && ($d <= $l)) {
$dow = 0;
$o .= '</tr><tr>';
@ -510,7 +513,7 @@ class Temporal
}
if ($dow) {
for ($a = $dow; $a < 7; $a ++) {
for ($a = $dow; $a < 7; $a++) {
$o .= '<td>&nbsp;</td>';
}
}