Ejemplo n.º 1
0
 /**
  * @param DateTimeParseResult $result
  *
  * @return LocalDateTime
  *
  * @throws DateTimeException      If the date-time is not valid.
  * @throws DateTimeParseException If required fields are missing from the result.
  */
 public static function from(DateTimeParseResult $result)
 {
     return new LocalDateTime(LocalDate::from($result), LocalTime::from($result));
 }
Ejemplo n.º 2
0
 /**
  * Obtains an instance of `LocalTime` from a text string.
  *
  * @param string              $text   The text to parse, such as `10:15`.
  * @param DateTimeParser|null $parser The parser to use, defaults to the ISO 8601 parser.
  *
  * @return LocalTime
  *
  * @throws DateTimeException      If the time is not valid.
  * @throws DateTimeParseException If the text string does not follow the expected format.
  */
 public static function parse($text, DateTimeParser $parser = null)
 {
     if (!$parser) {
         $parser = IsoParsers::localTime();
     }
     return LocalTime::from($parser->parse($text));
 }