/**
  * Parse the given formatted date according to the timezone set in this
  * DataConverter object.
  * If $pattern is given, parsing will be strictly by this pattern.
  * Otherwise, will try various localized patterns. Currently tries datetime
  * and then date.
  * 
  * @param String $formattedDate formatted date (or date & time)
  * @param String $pattern Optional pattern to use when formatting or parsing. 
  *               Patterns are documented at http://userguide.icu-project.org/formatparse/datetime
  * @return long unix timestamp
  */
 public function parseDate($formattedDate, $pattern = null)
 {
     if (!$formattedDate) {
         return null;
     }
     if ($pattern) {
         return $this->parseDateByPattern($formattedDate, $pattern);
     }
     // First try parsing as datetime
     $pattern = DataConverter::getDatePattern($this->locale, true, true);
     $timestamp = $this->parseDateByPattern($formattedDate, $pattern);
     if (is_numeric($timestamp)) {
         return $timestamp;
     }
     // If parsing failed, try parsing as date only
     $pattern = DataConverter::getDatePattern($this->locale, true, false);
     return $this->parseDateByPattern($formattedDate, $pattern);
 }
 /**
  * @covers DataConverter::getDatePattern
  * @expectedException IllegalArgumentException
  * @expectedExceptionMessage Date format must contain date or/and time
  */
 public function testGetDatePatternException()
 {
     $actual = \DataConverter::getDatePattern("Europe/Paris", false, false);
     $expected = "h:mm a";
     $this->assertEquals($expected, $actual);
 }
 /**
  * Format the given timestamp as time.
  * 
  * @param long $timestamp
  * @param boolean $showSeconds whether seconds should be included.
  * @return String formatted time, of the given timestamp in the
  *         timezone set for this Formatter object.
  */
 public function time($timestamp, $showSeconds = false)
 {
     if ($timestamp === null) {
         return '';
     }
     $pattern = DataConverter::getDatePattern($this->getLocaleName(), false, true, $showSeconds);
     $fmt = new IntlDateFormatter($this->getLocaleName(), null, null, $this->timezone, null, $pattern);
     return $fmt->format((int) $timestamp);
 }