Telegram repariert.

This commit is contained in:
Eskimue
2026-04-08 13:52:16 +02:00
parent b203078113
commit 9587024ff8
3 changed files with 24 additions and 5 deletions
+21 -2
View File
@@ -626,6 +626,11 @@ function parseWebObsPage(string $html): array
}
}
$magnitude = parseStrictDecimal($magnitudeText);
if ($magnitude === null) {
continue;
}
$jd = (float) str_replace(',', '.', $jdText);
$observedAtUtc = jdToUtcString($jd);
@@ -635,8 +640,8 @@ function parseWebObsPage(string $html): array
'jd' => number_format($jd, 6, '.', ''),
'observed_at_utc' => $observedAtUtc,
'calendar_date_text' => $calendarDateText !== '' ? $calendarDateText : null,
'magnitude' => normalizeNumeric($magnitudeText),
'magnitude_error' => $magnitudeErrorText !== '' ? normalizeNumeric($magnitudeErrorText) : null,
'magnitude' => $magnitude,
'magnitude_error' => $magnitudeErrorText !== '' ? parseStrictDecimal($magnitudeErrorText) : null,
'filter_code' => $filterCode !== '' ? $filterCode : null,
'observer_code' => $observerCode !== '' ? $observerCode : null,
'notes_raw' => $notesRaw,
@@ -662,6 +667,20 @@ function normalizeNumeric(string $value): string
return str_replace(',', '.', trim($value));
}
function parseStrictDecimal(string $value): ?string
{
$normalized = normalizeNumeric($value);
if ($normalized === '') {
return null;
}
if (preg_match('/^[+-]?\d+(?:\.\d+)?$/', $normalized) !== 1) {
return null;
}
return $normalized;
}
function jdToUtcString(float $jd): string
{
$jd += 0.5;