Retorna um DateTime conforme parametros passados.

@param       mixed $sW
Texto no formato "week" ou
array associativo com os dados brutos da data.

@return      ?DateTime
199616
public static function dateOfWeek($obj) : ?\DateTime
    {
        $oD = null;
        $wM = null;

        if ($obj !== null) {
            if (is_string($obj) === true) {
                $wM = self::weekMember($obj);
                $oD = self::dateOfWeek($wM);
            } else {
                if (is_array($obj) === true && isset($obj["year"]) === true && isset($obj["week"]) === true && isset($obj["day"]) === true) {
                    // ANO - Corrige valor fora dos limites válidos
                    $y = ($obj["year"] > 9999) ? 9999 : $obj["year"];
                    $y = ($y < 1) ? 1 : $y;

                    // SEMANA - Corrige valor fora dos limites válidos
                    $mW = self::weeksInYear($y);

                    $n = $obj["week"];
                    $n = ($n < 1) ? 1 : (($n > $mW) ? $mW : $n);

                    // Verifica set do dia da semana
                    $d = $obj["day"];

                    // DIA - Corrige valor fora dos limites válidos
                    $d = ($d < 1) ? 1 : (($d > 7) ? 7 : $d);

                    // Seta instância para o primeiro dia da primeira semana do ano alvo
                    $oD = self::firstWeekOfYear($y);

                    // Calcula quantidade de dias passados
                    $addD = ((($n - 1) * 7) + $d - 1);
                    $oD->add(new \DateInterval("P" . $addD . "D"));
                }
            }
        }

        return $oD;
    }
224186
public function formatDateUnknown($dateValue)
    {
        if ($dateValue) {
            return $this->formatDateTime($dateValue);
        } else {
            return \MUtil_Html::create()->span($this->_('unknown'), array('class' => 'disabled'));
        }
    }
713187
public static function lastWeekRange()
    {
        $timestamp = time();
        return [
            strtotime(date('Y-m-d', strtotime("last week Monday", $timestamp))),
            strtotime(date('Y-m-d', strtotime("last week Sunday", $timestamp))) + 24 * 3600 - 1
        ];
    }
136341
public function lastEarnedDate() : \DateTime
    {
        return new \DateTime(
            $this->comparing() ?
            $this->group->comparedUser->lastUpdateDate :
            $this->group->fromUser->lastUpdateDate
        );
    }
37691
public function getDate(): \DateTime
    {
        /*
            RFC2616 - 14.18 says all Responses need to have a Date.
            Make sure we provide one even if it the header
            has been removed in the meantime.
         */
        if (!$this->header->has('Date')) {
            $this->setDate(\DateTime::createFromFormat('U', (string) \time()));
        }

        return $this->header->getDate('Date');
    }
461213
public static function parse(string $text, DateTimeParser $parser = null) : TimeZone
    {
        if (! $parser) {
            $parser = IsoParsers::timeZoneRegion();
        }

        return TimeZoneRegion::from($parser->parse($text));
    }
328223
private function parseDate($text)
    {
        if (empty($text) || '-' == $text) {
            return null;
        }

        $date = \DateTime::createFromFormat('d/m/Y', $text);

        return false === $date ? null : $date->format('Y-m-d').'T00:00:00.000Z';
    }
602021
protected function dateWord($format){

        $timestamp = $this->getTimestamp();

        list($gYear, $gMonth, $gDay, $gWeek) = explode('-', date('Y-m-d-w', $timestamp));
        list($pYear, $pMonth, $pDay) = static::getJalali($gYear, $gMonth, $gDay);
        $pWeek = ($gWeek + 1);

        if ($pWeek >= 7) {
            $pWeek = 0;
        }

        if ($format == '\\') {
            $format = '//';
        }

        $lenghFormat = strlen($format);
        $i = 0;
        $result = '';

        $word = new Notowo(0, 'fa');

        while ($i < $lenghFormat) {
            $par = $format{$i};
            if ($par == '\\') {
                $result .= $format{ ++$i};
                $i ++;
                continue;
            }
            switch ($par) {
                # Day
                case 'd':
                case 'j':
                    $result .= $word->getWord(strval($pDay));
                    break;

                case 'D':
                    $result .= substr(static::$dayWeek[$pWeek], 0, 2);
                    break;

                case 'l':
                    $result .= static::$dayWeek[$pWeek];
                    break;

                case 'N':
                    $result .= $word->getWord(strval($pWeek + 1));
                    break;

                case 'w':
                    $result .= $word->getWord(strval($pWeek));
                    break;

                case 'z':
                    $result .= $word->getWord(strval($this->daysYear($pMonth, $pDay)));
                    break;

                case 'S':
                    $result .= self::NUMBER_TH;
                    break;

                # Week
                case 'W':
                    $result .= $word->getWord(strval(ceil($this->daysYear($pMonth, $pDay) / 7)));
                    break;

                # Month
                case 'F':
                    $result .= static::$monthYear[$pMonth-1];
                    break;

                case 'm':
                case 'n':
                    $result .= $word->getWord(strval($pMonth));
                    break;

                case 'M':
                    $result .= substr(static::$monthYear[$pMonth-1], 0, 6);
                    break;

                case 't':
                    $result .= $word->getWord(strval(static::isLeapYear($pYear) && ($pMonth == 12) ? 30 : static::$daysMonthJalali[intval($pMonth)-1]));
                    break;

                # Years
                case 'L':
                    $result .= intval($this->isLeapYear($pYear));
                    break;

                case 'Y':
                case 'o':
                    $result .= $word->getWord(strval($pYear));
                    break;

                case 'y':
                    $result .= $word->getWord(strval(substr($pYear, 2)));
                    break;

                # Time
                case 'a':
                case 'A':
                    if (date('a', $timestamp) == 'am') {
                        $result .= (($par == 'a') ? self::AM : self::ANTE_MERIDIEM);
                    } else {
                        $result .= (($par == 'a') ? self::PM : self::POST_MERIDIEM);
                    }
                    break;

                case 'B':
                case 'g':
                case 'G':
                case 'h':
                case 'H':
                case 's':
                case 'u':
                case 'i':
                    $result .= $word->getWord(strval(date($par, $timestamp)));
                    break;
                case 'e':
                case 'I':
                case 'O':
                case 'P':
                case 'T':
                case 'Z':
                    $result .= date($par, $timestamp);
                    break;

                # Full Date/Time
                case 'c':
                    $result .= $this->dateWord('Y, m, d, H:i:s P');
                    break;

                case 'r':
                    $result .=  $this->dateWord('l Y, m, d, H:i:s P');
                    break;

                case 'U':
                    $result .= $word->getWord(strval($timestamp));
                    break;

                default:
                    $result .= $par;
            }
            $i ++;
        }

        return $result;
    }
693233
public static function toStamp($time = null, $currentIsDefault = true): int
    {
        if ($time instanceof DateTime) {
            return $time->format('U');
        }

        if (null !== $time) {
            $time = is_numeric($time) ? (int)$time : strtotime($time);
        }

        if (!$time) {
            $time = $currentIsDefault ? time() : 0;
        }

        return $time;
    }
81234
public function getEndTimeObject($date_string = null)
    {
        if (null == $date_string)
        {
            $date_string = date('Y-m-d');
        }

        return new \DateTime($date_string.' '.$this->getEndTimeWithSeconds());
    }
677607
public static function date($format = "Y-m-d H:i:s", $time = null)
    {
        $time = ($time !== null ? $time : time());

        if (!is_numeric($time)) {
            $time = static::toUnix($time);
        }

        return date($format, $time);
    }
1183500
public function getLogDate() : DateTime
     {
        $rtn = $this->data['log_date'];

        if (!empty($rtn)) {
            $rtn = new DateTime($rtn);
        }

        return $rtn;
     }
77332
public function getDateAdded() : ?DateTime
     {
        $rtn = $this->data['date_added'];

        if (!empty($rtn)) {
            $rtn = new DateTime($rtn);
        }

        return $rtn;
     }
702622
private function formatDate(\DateTime $datetime = null, $format = 'Y_m_d')
    {
        if (null == $datetime) {
            $datetime = new \DateTime('now');
        }

        return $datetime->format($format);
    }
1025160
public static function stringToTime($str)
    {
        $l = self::getLocale();
        $date = \DateTime::createFromFormat($l->dateTimeFormat, $str);
        if (isset($date)) {
            return $date->getTimestamp();
        }
        $time = strtotime($str);
        if ($time === false) {
            return null;
        }
        return $time;
    }
219747
public function storageVal($val)
    {
        $val = $this->dateTimeVal($val);

        if ($val instanceof DateTimeInterface) {
            return $val->format('Y-m-d H:i:s');
        } else {
            if ($this->allowNull()) {
                return null;
            } else {
                throw new Exception(
                    'Invalid date/time value. Must be a DateTimeInterface instance.'
                );
            }
        }
    }
675511
public function getDateOfBirth() : ?DateTime
     {
        $rtn = $this->data['date_of_birth'];

        if (!empty($rtn)) {
            $rtn = new DateTime($rtn);
        }

        return $rtn;
     }