Get a log or fail

@param  string  $date

@return Log|null
768347
private function getLogOrFail($date)
    {
        try {
            return $this->viewer->get($date);
        } catch (Exception $e) {
            return abort(404, $e->getMessage());
        }
    }
1264895
public function getAge($date = NULL)
    {
        if (is_null($date)) {
            $date = new \MUtil_Date();
        }

        if ($date instanceof \MUtil_Date) {
            // Now calculate age
            $birthDate = $this->getBirthDate();
            if ($birthDate instanceof \Zend_Date) {
				$age = $date->get('Y') - $birthDate->get('Y');
				if ($date->get('MMdd') < $birthDate->get('MMdd')) {
					$age--;
				}
			} else {
				return;
			}
        }

        return $age;
    }
982725
public static function dateFormToSQL($date)
    {
        list($d, $m, $y) = @explode("/", $date);
        $month = (int)$m;
        $day   = (int)$d;
        $year  = (int)$y;
        if (checkdate($month, $day, $year)) {
            if ($day < 10) {
                $day = '0' . $day;
            }
            if ($month < 10) {
                $month = '0' . $month;
            }

            return $y . '-' . $month . '-' . $day;
        } else {
            return '';
        }
    }
457780
public function setDateTimeFrom($date = null)
    {
        $date = $this->resolveCarbon($date);

        return $this->modify($date->rawFormat('Y-m-d H:i:s.u'));
    }
836486
public function evaluateExclusions($date = null)
    {
        if (!$date) {
            $date = clone $this->now;
        }
        // Check dates of exclusion (if there are any).
        $jsonHelper       = new JSONHelper();
        $exclusionsString = $this->contactClient->getScheduleExclusions();
        $exclusions       = $jsonHelper->decodeArray($exclusionsString, 'ScheduleExclusions');
        if ($exclusions) {
            // Fastest way to compare dates is by string.
            $todaysDateString = $date->format('Y-m-d');
            foreach ($exclusions as $exclusion) {
                if (!empty($exclusion->value)) {
                    $dateString   = trim(str_ireplace('yyyy-', '', $exclusion->value));
                    $segments     = explode('-', $dateString);
                    $segmentCount = count($segments);
                    if (3 == $segmentCount) {
                        $year  = !empty($segments[0]) ? str_pad(
                            $segments[0],
                            4,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format(
                            'Y'
                        );
                        $month = !empty($segments[1]) ? str_pad(
                            $segments[1],
                            2,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format('m');
                        $day   = !empty($segments[2]) ? str_pad(
                            $segments[2],
                            2,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format('d');
                    } elseif (2 == $segmentCount) {
                        $year  = $date->format('Y');
                        $month = !empty($segments[0]) ? str_pad(
                            $segments[0],
                            2,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format('m');
                        $day   = !empty($segments[1]) ? str_pad(
                            $segments[1],
                            2,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format('d');
                    } else {
                        continue;
                    }
                    $dateString = $year.'-'.$month.'-'.$day;
                    if ($dateString == $todaysDateString) {
                        throw new ContactClientException(
                            'This contact client does not allow contacts on the date '.$dateString.'.',
                            0,
                            null,
                            Stat::TYPE_SCHEDULE,
                            false
                        );
                    }
                }
            }
        }

        return $this;
    }
419155
protected static function strBrToUs($date)
    {
        if (is_string($date)) {
            $expreg = '/^(0[1-9]|[1-2][0-9]|3[0-1])\/(0[1-9]|1[0-2])\/(\d{4})(T| ){0,1}(([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])){0,1}$/';
            if (preg_match($expreg, $date, $datebit)) {
                @list($tudo, $dia, $mes, $ano, $tz, $time, $hora, $min, $seg) = $datebit;

                return "$ano-$mes-$dia" . ($hora | $min | $seg ? "$hora:$min:$seg" : "");
            }
        }
        return null;
    }
174504
public function getTargetFromDate($date)
    {
        if (!preg_match('/^\d{4,14}$/', $date)) {
            throw new \InvalidArgumentException('Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].');
        }

        // what we need to append to the date according to the possible date string lengths
        $dateStrlenToAppend = [
            14 => '',
            12 => '00',
            10 => '0000',
            8 => '000000',
            6 => '01000000',
            4 => '0101000000',
        ];

        if (!isset($dateStrlenToAppend[strlen($date)])) {
            throw new \InvalidArgumentException('Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].');
        }

        $target = $date . $dateStrlenToAppend[strlen($date)];

        $dateTime = \DateTime::createFromFormat('YmdHis', $target);

        if ($dateTime === false) {
            throw new \InvalidArgumentException('Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].');
        }

        return $dateTime->format('YmdHis');
    }
1353977
public function getDate($date, string $pattern = "Y-m-d")
    {
        if (!$date) {
            $this->data['ano'] = date("Y");
            $this->data['mes'] = date("m");
            $this->data['dia'] = date("d");
        } else {
            $this->prepareDate($date);
        }

        if($this->erro) {
            return null;
        } else {
            $originalDate = $this->data['ano'] . '-' . $this->data['mes'] . '-' . $this->data['dia'];
            return date($pattern, strtotime($originalDate));
        }
    }
762189
public static function date($date){

		$Date = static::_utcZeroDateTime($date);

		if($Date === null){

			return $date;
		}

		return $Date->format('Y-m-d');
	}
681718
public static function isDate($date): bool
    {
        if (!\preg_match('/^([\d]{4})-((?:0?[\d])|(?:1[0-2]))-((?:0?[\d])|(?:[1-2][\d])|(?:3[01]))( [\d]{2}:[\d]{2}:[\d]{2})?$/',
            $date, $matches)) {
            return false;
        }

        return \checkdate((int)$matches[2], (int)$matches[3], (int)$matches[1]);
    }
636943
public function validateDate($date)
    {
        $subs = null;
        $check1 = preg_match("/^([\d]{4})-([\d]{2})-([\d]{2})$/i", $date, $subs);
        if(!$check1) {
            return false;
        }
        return checkdate($subs[2], $subs[3], $subs[1]);
    }
486003
public function get($date, $default = null)
    {
        if (!$this->has($date)) {
            return false;
        }
        return parent::get($date, $default);
    }
723750
public static function sunday($date = null)
    {
        if ($date) {
            return Carbon::parse($date)->startOfWeek(Carbon::SUNDAY);
        }

        return Carbon::now()->startOfWeek(Carbon::SUNDAY);
    }
824726
public static function dateSQL($date, $format = 'd-m-Y')
    {
        if (empty($date)) {
            return null;
        }

        $obj = DateTime::createFromFormat('Y-m-d H:i:s', $date);
        if (empty($obj)) {
            return null;
        }

        return $obj->format($format);
    }
551313
public function get($date, $default = null)
    {
        if (!$this->has($date)) {
            throw new Exception('Log not found in this date [' . $date . ']');
        }

        return parent::get($date, $default);
    }
420030
public static function is($date)
    {
        if (is_bool($date) || empty($date) xor ($date === 0 || $date === '0')) {
            return false;
        }
        $date = static::isTimestamp($date) ? '@' . (string)$date : $date;
        return (bool)date_create($date);
    }
695058
protected function convertToSqlDateTime($date)
    {
        if ($date instanceof \DateTime) {
            $date = $this->expr()->literal($date->format(self::SQL_DATE_TIME));
        }

        return $date;
    }