/**
  * Constructor.
  *
  * @param string $inputTimezone  The input timezone
  * @param string $outputTimezone The output timezone
  * @param array  $fields         The date fields
  * @param bool   $pad            Whether to use padding
  *
  * @throws UnexpectedTypeException if a timezone is not a string
  */
 public function __construct($inputTimezone = null, $outputTimezone = null, array $fields = null, $pad = false)
 {
     parent::__construct($inputTimezone, $outputTimezone);
     if (null === $fields) {
         $fields = ['year', 'month', 'day', 'hour', 'minute', 'second'];
     }
     $this->fields = $fields;
     $this->pad = (bool) $pad;
 }
 /**
  * Transforms a \DateTime instance to a string.
  *
  * @see \DateTime::format() for supported formats
  *
  * @param string $inputTimezone  The name of the input timezone
  * @param string $outputTimezone The name of the output timezone
  * @param string $format         The date format
  * @param bool   $parseUsingPipe Whether to parse by appending a pipe "|" to the parse format
  *
  * @throws UnexpectedTypeException if a timezone is not a string
  */
 public function __construct($inputTimezone = null, $outputTimezone = null, $format = 'Y-m-d H:i:s', $parseUsingPipe = true)
 {
     parent::__construct($inputTimezone, $outputTimezone);
     $this->generateFormat = $this->parseFormat = $format;
     $this->parseUsingPipe = $parseUsingPipe || null === $parseUsingPipe;
     // See http://php.net/manual/en/datetime.createfromformat.php
     // The character "|" in the format makes sure that the parts of a date
     // that are *not* specified in the format are reset to the corresponding
     // values from 1970-01-01 00:00:00 instead of the current time.
     // Without "|" and "Y-m-d", "2010-02-03" becomes "2010-02-03 12:32:47",
     // where the time corresponds to the current server time.
     // With "|" and "Y-m-d", "2010-02-03" becomes "2010-02-03 00:00:00",
     // which is at least deterministic and thus used here.
     if ($this->parseUsingPipe && false === strpos($this->parseFormat, '|')) {
         $this->parseFormat .= '|';
     }
 }
 /**
  * Constructor.
  *
  * @see BaseDateTimeTransformer::formats for available format options
  *
  * @param string $inputTimezone  The name of the input timezone
  * @param string $outputTimezone The name of the output timezone
  * @param int    $dateFormat     The date format
  * @param int    $timeFormat     The time format
  * @param int    $calendar       One of the \IntlDateFormatter calendar constants
  * @param string $pattern        A pattern to pass to \IntlDateFormatter
  *
  * @throws UnexpectedTypeException If a format is not supported or if a timezone is not a string
  */
 public function __construct($inputTimezone = null, $outputTimezone = null, $dateFormat = null, $timeFormat = null, $calendar = \IntlDateFormatter::GREGORIAN, $pattern = null)
 {
     parent::__construct($inputTimezone, $outputTimezone);
     if (null === $dateFormat) {
         $dateFormat = \IntlDateFormatter::MEDIUM;
     }
     if (null === $timeFormat) {
         $timeFormat = \IntlDateFormatter::SHORT;
     }
     if (!in_array($dateFormat, self::$formats, true)) {
         throw new UnexpectedTypeException($dateFormat, implode('", "', self::$formats));
     }
     if (!in_array($timeFormat, self::$formats, true)) {
         throw new UnexpectedTypeException($timeFormat, implode('", "', self::$formats));
     }
     $this->dateFormat = $dateFormat;
     $this->timeFormat = $timeFormat;
     $this->calendar = $calendar;
     $this->pattern = $pattern;
 }