Show dates in localized format

This commit is contained in:
pezcurrel 2023-01-07 12:56:32 +01:00
parent 9cb1f272cc
commit fac6a32d87

View file

@ -377,6 +377,11 @@ function tquery($query,$line) {
return($res);
}
$dfmt=datefmt_create($blang,IntlDateFormatter::MEDIUM,IntlDateFormatter::NONE,'UTC',IntlDateFormatter::GREGORIAN);
$defmt=datefmt_create($blang,IntlDateFormatter::SHORT,IntlDateFormatter::MEDIUM,'UTC',IntlDateFormatter::GREGORIAN);
$wrfss=1602633600;// we record FirstSeen since October 14, 2020, 0:0:0 UTC
$wrfsstxt=datefmt_format($dfmt,$wrfss).' UTC';
mysqli_data_seek($res,$if);
while ($if<$il && $row=mysqli_fetch_assoc($res)) {
$if++;
@ -413,15 +418,16 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
$out.='</div>'.N;
$out.='<div class="icol">'.N;
if (is_null($row['FirstSeen'])) {// can't currently happen, because main query excludes on FirstSeen = null; but we put it there in any event
$fseen='<span class="null">'._('Not available{singular}').'</span>';
} elseif ($row['FirstSeen']<1602626400) {// 1602626400 is October 14, 2020, 0:0:0 - we have FirstSeen only since October 13, 2020, so...
$fseen='<span class="nulltip" title="'._('We record this value only since October 14, 2020 ;-)').'">'._('Before October 14, 2020').'</span>';
if (is_null($row['FirstSeen'])) {// can't currently happen, but we put it there in any event
$fdate='<span class="null">'._('Not available{singular}').'</span>';
} elseif ($row['FirstSeen']<$wrfss) {
$fdate='<span class="nulltip" title="'._('We record this value only since').' '.$wrfsstxt.' ;-)">'._('Before').' '.$wrfsstxt.'</span>';
} else {
$fseen=ldate($row['FirstSeen'],true);
$fdate=datefmt_format($dfmt,$row['FirstSeen']).' UTC';
}
$out.='<div><span class="ilab">'._('First sight').'</span> '.$fseen.'</div>'.N;
$out.='<div><span class="ilab">'._('Last successful check').'</span> '.nully(ldate($row['LastOkCheckTS'],true)).'</div>'.N;
$out.='<div><span class="ilab">'._('First sight').'</span> '.$fdate.'</div>'.N;
(is_null($row['LastOkCheckTS'])) ? $fdate='<span class="null">'._('Not available{singular}').'</span>' : $fdate=datefmt_format($dfmt,$row['LastOkCheckTS']).' UTC';
$out.='<div><span class="ilab">'._('Last successful check').'</span> '.$fdate.'</div>'.N;
$out.='<div><span class="ilab">'._('Noxious').'</span> ';
($row['Noxious']==1) ? $out.='<span class="ibad">'._('Yes (see why below)').'</span>' : $out.='<span class="igood">'._('No').'</span>';
$out.='</div>'.N;
@ -505,7 +511,8 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
} elseif ($row['AdmAccount']=='OPTED OUT') {
$admacc='<span class="null">'._('Opted out of search engines indexing').'</span>';
}
$out.='<div class="abox"><img class="aimg" src="'.$thumb.'"><div><span class="ilab">'._('Admin account').'</span> '.$admacc.'</div><div><span class="ilab">'._('Date of creation').'</span> '.nully(ldate($row['AdmCreatedAt'],true)).'</div><div><span class="ilab">'._('Display name').'</span> '.nully(hspech($row['AdmDisplayName'])).'</div><div><div class="idlab">'._('Bio').'</div><div class="inote">'.nully(strip($row['AdmNote'],$row['URI'])).'</div>'.N;
(is_null($row['AdmCreatedAt'])) ? $fdate='<span class="null">'._('Not available{singular}').'</span>' : $fdate=datefmt_format($dfmt,$row['AdmCreatedAt']).' UTC';
$out.='<div class="abox"><img class="aimg" src="'.$thumb.'"><div><span class="ilab">'._('Admin account').'</span> '.$admacc.'</div><div><span class="ilab">'._('Date of creation').'</span> '.$fdate.'</div><div><span class="ilab">'._('Display name').'</span> '.nully(hspech($row['AdmDisplayName'])).'</div><div><div class="idlab">'._('Bio').'</div><div class="inote">'.nully(strip($row['AdmNote'],$row['URI'])).'</div>'.N;
$out.='</div></div>';
$out.='<div class="ghost"><div class="idlab">'._('Stats').'</div><div class="istat">';
@ -538,7 +545,7 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
for ($i=$tot-1; $i>=0; $i--) {
$out.='<td width="'.(100/$tot).'%"';
if ($buf[$i]['Status']==1) $out.=' class="cbarok"';
$out.='>'.ldate($buf[$i]['Time']).'</td>';
$out.='>'.datefmt_format($defmt,$buf[$i]['Time']).' UTC</td>';
}
$out.='</tr></table>'.N;
$out.='<div class="dida100">'._('Succesful checks').': '.$row['OkChecks'].'/'.$row['TotChecks'].' ('.round(100 / $row['TotChecks'] * $row['OkChecks'], 2).'%)</div>'.N;
@ -608,15 +615,6 @@ function nullemp($inp) {
return(false);
}
function ldate($ts,$dateonly=false) {
if (nullemp($ts)) return(null);
$ts=round($ts);
if (!$dateonly)
return(gmdate('d/m/Y H:i:s e',$ts));
else
return(gmdate('d/m/Y e',$ts));
}
function hspech($str) {
if (nullemp($str)) return(null);
return(htmlspecialchars($str,ENT_QUOTES|ENT_HTML5,'UTF-8'));