Changeset 24


Ignore:
Timestamp:
Dec 26, 2018, 10:45:44 PM (6 years ago)
Author:
chronos
Message:
  • Fixed: Wrong age calculation from message text.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Import/Csts.php

    r20 r24  
    3333      $MeetItem->Height = trim(GetTextBetween($Item, "výška:", 'cm'));
    3434      $MeetItem->Message = trim(html_entity_decode(strip_tags(GetTextBetween($Item, '<td colspan="3">', '</td>'))));
     35      // Replace unicode non-breakable space by normal space
     36      $MeetItem->Message = str_replace("\xc2\xa0", "\x20", $MeetItem->Message);     
    3537      $MeetItem->Age = GetAgeFromText($MeetItem->Message);     
    3638      $MeetItem->Height = GetHeightFromText($MeetItem->Message);
  • trunk/Meet.php

    r23 r24  
    104104}
    105105
     106function is_white_space($Char)
     107{
     108  return ($Char == ' ') or ($Char == "\t");
     109}
     110
    106111function GetNumberBeforeText($Text, $Needle)
    107112{
     
    120125      $Text = substr($Text, $Pos + 1);
    121126      $Start = $Pos - 1;
    122       while (($Start >= 0) and (is_numeric($Result[$Start]) or ($Result[$Start] == ' ')))
     127      while (($Start >= 0) and (is_numeric($Result[$Start]) or is_white_space($Result[$Start])))
    123128        $Start--;
    124129      $Start++;
     
    146151      $Text = substr($Text, $Pos + 1);
    147152      $End = 0;
    148       while (($End < strlen($Result)) and (is_numeric($Result[$End]) or ($Result[$End] == ' ')))
     153      while (($End < strlen($Result)) and (is_numeric($Result[$End]) or is_white_space($Result[$End])))
    149154        $End++;
    150155      $End--;
     
    167172  if ($Result == '') $Result = GetNumberAfterText($Text, 'čerstvých');
    168173  if ($Result == '') $Result = GetAgeHeightWeightFromText($Text)[0];
    169   if ($Result == '') $Result = date('Y', time()) - GetNumberAfterText($Text, 'ročník');
     174  if ($Result == '') {
     175    $Year = GetNumberAfterText($Text, 'ročník');
     176    if ($Year != '') $Result = date('Y', time()) - $Year;
     177  }
    170178  return $Result;
    171179}
Note: See TracChangeset for help on using the changeset viewer.