Esempio n. 1
0
 private static function parseFraction($text, $parsed, $negate)
 {
     // regex limits to [0-9]{0,9}
     if ($parsed === null || strlen($parsed) === 0) {
         return 0;
     }
     try {
         $parsed = substr($parsed . "000000000", 0, 9);
         return Integer::parseInt($parsed) * $negate;
     } catch (\Exception $ex) {
         throw new DateTimeParseException("Text cannot be parsed to a Duration: fraction", $text, 0, $ex);
     }
 }
Esempio n. 2
0
 private static function parseNumber($text, $str, $negate)
 {
     if ($str === null) {
         return 0;
     }
     $val = Integer::parseInt($str);
     try {
         return Math::multiplyExact($val, $negate);
     } catch (ArithmeticException $ex) {
         throw new DateTimeParseException("Text cannot be parsed to a Period", $text, 0, $ex);
     }
 }