示例#1
0
 public function testToString()
 {
     $this->assertSame('2008-12-31/2011-01-01', (string) LocalDateRange::of(LocalDate::of(2008, 12, 31), LocalDate::of(2011, 1, 1)));
 }
示例#2
0
 /**
  * Obtains an instance of `LocalDateRange` from a text string.
  *
  * Partial representations are allowed; for example, the following representations are equivalent:
  *
  * - `2001-02-03/2001-02-04`
  * - `2001-02-03/02-04`
  * - `2001-02-03/04`
  *
  * @param string              $text   The text to parse.
  * @param DateTimeParser|null $parser The parser to use, defaults to the ISO 8601 parser.
  *
  * @return LocalDateRange
  *
  * @throws DateTimeException      If either of the dates 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::localDateRange();
     }
     return LocalDateRange::from($parser->parse($text));
 }
示例#3
0
 /**
  * @param integer        $y1    The expected year of the start date.
  * @param integer        $m1    The expected month-of-year of the start date.
  * @param integer        $d1    The expected day-of-month of the start date.
  * @param integer        $y2    The expected year of the end date.
  * @param integer        $m2    The expected month-of-year of the end date.
  * @param integer        $d2    The expected day-of-month of the end date.
  * @param LocalDateRange $range The LocalDateRange instance to test.
  */
 protected function assertLocalDateRangeIs($y1, $m1, $d1, $y2, $m2, $d2, LocalDateRange $range)
 {
     $this->assertLocalDateIs($y1, $m1, $d1, $range->getStartDate());
     $this->assertLocalDateIs($y2, $m2, $d2, $range->getEndDate());
 }