Fix bug in time splitter, make code more explicit

This commit is contained in:
Joshua Ramon Enslin 2022-01-09 22:19:22 +01:00
parent 109f18e63c
commit 9132745631
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 3 additions and 3 deletions

View File

@ -1016,7 +1016,7 @@ final class NodaTimeSplitter {
// Skip 1200-1300
if (!empty(self::attempt_splitting($datum))) return [];
if (strlen($datum) === 9 and substr($datum, 4, 1)) return [];
if (strlen($datum) === 9 and substr($datum, 4, 1) !== '-') return [];
if (empty($startEnd = self::check_is_timespan_from_till($datum))) {
return [];

View File

@ -1094,7 +1094,7 @@ final class NodaWikidataFetcher {
$datafromwiki = MD_STD::runCurl("https://" . urlencode($sprache) . ".wikipedia.org/w/api.php?action=parse&page=" . urlencode($wikilinkterm[$sprache]) . "&prop=text&section=0&format=json", 10000);
$datafromwiki = json_decode($datafromwiki, true)['parse']['text']['*'];
if (!empty($datafromwiki) and $datafromwiki = self::_cleanWikidataInput((string)$datafromwiki)) {
if (!empty($datafromwiki) and !empty($datafromwiki = self::_cleanWikidataInput((string)$datafromwiki))) {
$alreadyEntered = $this->enterPlaceDescFromWikidata($currentPlaceResult, $datafromwiki, $wikilink, $lang, $sprache, $onum, $erfasst_von);
}
@ -1729,7 +1729,7 @@ final class NodaWikidataFetcher {
$birth_date_int = strtotime(substr($inputTime, 1, 4));
if ($birth_date_int) {
$birth_date = date("Y", $birth_date_int);
if ($birth_date === date("Y") and $tTime = strtotime($inputTime)) {
if ($birth_date === date("Y") and ($tTime = strtotime($inputTime)) !== false) {
$birth_date = date("Y", $tTime);
}