Changeset 24 for trunk/Meet.php


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

Legend:

Unmodified
Added
Removed
  • 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.