Returns a standard media path from supplied type and date.

@param  string   $type The media type
@param  DateTime $date The date to use in the path
@return string
503984
protected function getFilePath($type = 'image', DateTime $date = null)
    {
        $date = $date ?: new DateTime();
        return sprintf('files/base/%s/%s/%s/%s/%s', $this->getAccountKey(), $this->getGroupKey(), $type, $date->format('Y'), $date->format('m'));
    }
217777
public function toSqlDate(DateTimeInterface $date, Provider $provider = null) : string
    {
        $this->setParameterProvider($provider);

        return $date->format($provider->getDateFormat());
    }
573870
public function findByDate(\DateTime $date = null)
    {
        $date = $date ?: new \DateTime();

        return $this->repository->findByDate($date);
    }
856980
public function getByDate(string $date)
    {
        // Log Debug
        $this->flow->getLogger()->debug("Retrieving Settlement by Date $date");

        return $this->make(
            $this->performGet(
                'date',
                $date,
                [
                    'method' => 'getByDate',
                ]
            )
        );
    }
1338813
private static function cast(Date $date = null)
	{
		if (!is_null($date))
		{
			$date = new DateTime($date);
		}

		return $date;
	}
86709
private function getMediaByType($type)
    {
        $collection = [];
        $media = $this->getMedia();
        if (!$media) {
            return $collection;
        }
        foreach ($media as $asset) {
            if ($asset->isTypeOf($type)) {
                $collection[] = $asset;
            }
        }

        return $collection;
    }
275698
public static function dateFormat($date, $time=false) 
	{
		if(is_numeric($date) && (int)$date == $date)
			$date = date('Y-m-d H:i:s', $date);
		
		$setting = OmmuSettings::model()->findByPk(1, array(
			'select' => 'site_dateformat, site_timeformat',
		));
		
		if($time == true) {
			$date = date($setting->site_dateformat, strtotime($date)).' '.date($setting->site_timeformat, strtotime($date)).' WIB';
		} else{
			$date = date($setting->site_dateformat, strtotime($date));
		}
		return $date;
	}
270736
public static <T extends Comparable<?>> DatePath<T> datePath(Class<? extends T> type, PathMetadata metadata) {
        return new DatePath<T>(type, metadata);
    }
327031
private function _datePad($date, $type = 'year')
    {
        $padLength = $type == 'year' ? 4 : 2;
        $newDate = str_pad($date, $padLength, '0', STR_PAD_LEFT);

        return $newDate;
    }
1346450
public function textualDateFilter($date)
    {
        if ( ! $date instanceof \DateTime) {
            throw new \InvalidArgumentException('Textual Date Filter expects input to be a instance of DateTime');
        }

        $now  = new \DateTime('now');
        $diff = $now->diff($date);

        $diffUnit          = $this->getHighestDiffUnitAndValue($diff);
        $temporalModifier  = ($diff->invert)? 'ago':'next';
        $translationString = $temporalModifier. '.' .$diffUnit['unit'];

        // Override yesterday and tomorrow
        if ($diffUnit['unit'] == 'd' && $diffUnit['value'] == 1) {
            $translationString = ($diff->invert)? 'date.yesterday':'date.tomorrow';
        }

        // Override "just.now"
        if ($diffUnit['unit'] == 'now') {
            $translationString = 'date.just_now';
        }

        return $this->translator->transChoice($translationString, $diffUnit['value'], array('%value%' => $diffUnit['value']), 'date');
    }
1269212
private function getDateTimeType(): Type
    {
        if ($this->dateTimeType === null) {
            $this->dateTimeType = Type::getType(DateTimeType::DATETIME);
        }

        return $this->dateTimeType;
    }
1043190
public function dateIsLater(\DateTime $date) {
    $dateLater = FALSE;

    $t2 = $this->end_date->getTimeStamp();

    $t4 = $date->getTimestamp();

    if ($t2 < $t4) {
      $dateLater = TRUE;
    }

    return $dateLater;
  }
927220
protected function convertDate($date) : string
    {
        if (is_a($date, 'DateTime')) {
            return (string) $date->format(DateTime::ISO8601);
        }

        return $date;
    }
740587
public static function splitDate($dateTime, $type = 'int')
    {
        $t  = explode(' ', $dateTime);
        $t1 = explode('-', $t[0]);
        $t2 = explode(':', $t[1]);
        if ($type == 'int') {
            $x['date']   = (int)$t1[2];
            $x['month']  = (int)$t1[1];
            $x['year']   = (int)$t1[0];
            $x['hour']   = (int)$t2[0];
            $x['minute'] = (int)$t2[1];
            $x['second'] = (int)$t2[2];
        } else { // string
            $x['date']   = $t1[2];
            $x['month']  = $t1[1];
            $x['year']   = $t1[0];
            $x['hour']   = $t2[0];
            $x['minute'] = $t2[1];
            $x['second'] = $t2[2];
        }

        return $x;
    }
36421
public function sinceAlmost(Date $date = null)
	{
		return $this->datetime->sinceAlmost(self::cast($date));
	}
873890
public function download($date)
    {
        app('antares.logger')->setOld(['name' => $this->logViewer->get($date)->getFilename()])->keep('medium');
        return $this->logViewer->download($date);
    }
996009
public static function getDateTime($date)
    {
        $_date = time();

        if (isset($date) && self::isValidDate($date)) {
            $_date = strtotime(preg_replace('/\(.*?\)/', '', $date));
        }

        return date('Y-m-d H:i:s', $_date);
    }