Telegram repariert.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user