@param $date string Search for Schedule resources that have a period that contains this date specified
@return string

Returns a FHIR JSON or XML string
in response
166939
public function getSchedule($date)
    {
        $weekend = array('Sat', 'Sun');
        $scheduleStart = '08:00:00';
        $scheduleEnd = '17:00:00';

        if(!$date) {
            $date = date('Y-m-d');
        }
        $startStr = $date . ' ' . $scheduleStart;
        $endStr = $date . ' ' . $scheduleEnd;
        $dateArr = explode('-', $date);
        $mk_time = mktime(0, 0, 0, $dateArr[1], $dateArr[2], $dateArr[0]);
        $day = date('D', $mk_time);

        $fhirSchedule = new FHIRSchedule();
        if(!in_array($day, $weekend)) {

            $planningHorizon =	new FHIRPeriod();
            $dateTimeStart = new FHIRDateTime();
            $dateTimeStart->setValue($startStr);
            $planningHorizon->setStart($dateTimeStart);
            $dateTimeEnd = new FHIRDateTime();
            $dateTimeEnd->setValue($endStr);
            $planningHorizon->setEnd($dateTimeEnd);
            $fhirSchedule->setPlanningHorizon($planningHorizon);
        }
        return $fhirSchedule;
    }
1169083
private function parseRequestDate($date)
    {
        $timezone = new \DateTimeZone("UTC");
        $granularity = null;

        if (preg_match('#^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$#', $date)) {
            $parsedDate = date_create_from_format('Y-m-d\TH:i:s\Z', $date, $timezone);
            $granularity = Identity::GRANULARITY_YYYY_MM_DDTHH_MM_SSZ;
        } elseif (preg_match('#^\d{4}-\d{2}-\d{2}$#', $date)) {
            // Add ! to format to set time to 00:00:00
            $parsedDate = date_create_from_format('!Y-m-d', $date, $timezone);
            $granularity = Identity::GRANULARITY_YYYY_MM_DD;
        } else {
            throw new BadArgumentException("Expected a data in one of the following formats: " .
                Identity::GRANULARITY_YYYY_MM_DDTHH_MM_SSZ . " OR " .
                Identity::GRANULARITY_YYYY_MM_DD ." FOUND " . $date);
        }

        $parseResult = date_get_last_errors();
        if (!$parsedDate || ($parseResult['error_count'] > 0) || ($parseResult['warning_count'] > 0)) {
            throw new BadArgumentException("$date is not a valid date");
        }

        return [$parsedDate, $granularity];
    }
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;
    }
1063215
public function parse($date)
	{
		foreach ($this->user as $method)
		{
			if (($returned = call_user_func($method, $date)) !== false)
			{
				return $returned;
			}
		}

		foreach ($this->built_in as $method)
		{
			if (($returned = call_user_func(array($this, $method), $date)) !== false)
			{
				return $returned;
			}
		}

		return false;
	}
745673
protected function _checkDateFormat( $date )
	{
		$regex = '/^[0-9]{4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]$/';

		if( $date !== null && preg_match( $regex, $date ) !== 1 ) {
			throw new MShop_Exception( sprintf( 'Invalid characters in date "%1$s". ISO format "YYYY-MM-DD hh:mm:ss" expected.', $date ) );
		}
	}
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));
        }
    }
748707
public static function getFormattedDate($date, $format)
    {
        if (StringUtils::isEmpty($date) || StringUtils::isEmpty($format)) {
            return null;
        }

        return date($format, strtotime($date));
    }
250349
public function cleanDate($date)
    {
        $response = $this->query($this->prepareUri('clean/birthdate'), [$date]);
        $result = $this->populate(new Date, $response);
        if (!$result instanceof Date) {
            throw new RuntimeException('Unexpected populate result: ' . get_class($result). '. Expected: ' . Date::class);
        }

        return $result;
    }
946131
public static function shortDate($date)
    {
        if (self::isDate($date)) {
            $str = self::dateTimeToTimeStamp($date);
            $string = date("d.m.Y", $str);
            return $string;
        } else {
            return null;
        }
    }
1280558
protected function _formatDate($date)
    {
        $clearDate = trim($date, '\'" ');
        //brak daty, pusty zwrot
        if (!$clearDate || $clearDate == 'false') {
            return;
        }
        return date($this->getFormat(), strtotime($clearDate));
    }
1054480
public function translateMonths(string $date)
    {
        foreach (array_flip($this->getMonthTranslationMap()) as $translated => $english) {
            if (false !== strpos($date, $english)) {
                $date = str_replace($english, $translated, $date);
            }
        }

        foreach (array_flip($this->getShortMonthTranslationMap()) as $translated => $english) {
            if (false !== strpos($date, $english)) {
                $date = str_replace($english, $translated, $date);
            }
        }

        return $date;
    }
818137
public function getUserDate($date)
    {
        $date = DBDatetime::create()->setValue($date);
        $member = Security::getCurrentUser();
        return $date->FormatFromSettings($member);
    }
886822
public function get(string $date = null) : array
    {
        if ($date === null) {
            $date = \date('Y-m-d');
        }

        return [
            'queued' => $this->queue->count(),
            'pass' => $this->queue->getStatsByType($date, 'pass'),
            'fail' => $this->queue->getStatsByType($date, 'fail'),
            'retry' => $this->queue->getStatsByType($date, 'retry'),
            'cancel' => $this->queue->getStatsByType($date, 'cancel')
        ];
    }
563164
public static function toString($date, $pattern = "Y-m-d H:i")
    {
        if ($date && is_object($date) && ($date instanceof \MongoDate)) {
            return date($pattern, $date->sec);
        } elseif (is_int($date)) {
            return date($pattern, $date);
        }
    }
371327
public function ContextsContainDate( $date )
	{
		if ( is_string( $date ) )
			$date = DateTime::createFromFormat( "!Y-m-d", $date );

		if ( ! is_a( $date, 'DateTime' ) )
		{
			throw new Exception( 'Date parameter passes to ContextsFilter::ContextsContainDate is not a string or DateTime object' );
		}

		$filtered = array_filter( $this->contexts, function ( $context ) use( $date ) {
			// The context may be invalid in which case exclude
			if ( ! isset( $context['period'] ) || ! isset( $context['period']['startDate'] ) || ! isset( $context['period']['endDate'] ) ) return false;

			$startDate = DateTime::createFromFormat( "!Y-m-d", $context['period']['startDate'] );
			if ( ! $context['period']['is_instant'] && $startDate >= $date ) return false;

			$endDate   = DateTime::createFromFormat( "!Y-m-d", $context['period']['endDate'] );
			return $context['period']['is_instant'] ? $endDate == $date : $endDate >= $date;
		} );

		return new ContextsFilter( $this->instance, $filtered );
	}
1287265
public function date_asctime($date)
	{
		static $pcre;
		if (!$pcre)
		{
			$space = '[\x09\x20]+';
			$wday_name = $this->day_pcre;
			$mon_name = $this->month_pcre;
			$day = '([0-9]{1,2})';
			$hour = $sec = $min = '([0-9]{2})';
			$year = '([0-9]{4})';
			$terminator = '\x0A?\x00?';
			$pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i';
		}
		if (preg_match($pcre, $date, $match))
		{
			/*
			Capturing subpatterns:
			1: Day name
			2: Month
			3: Day
			4: Hour
			5: Minute
			6: Second
			7: Year
			*/

			$month = $this->month[strtolower($match[2])];
			return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]);
		}

		return false;
	}
518807
public function translateMonthsToEnglish(string $date)
    {
        foreach ($this->getMonthTranslationMap() as $english => $translated) {
            if (false !== strpos($date, $translated)) {
                $date = str_replace($translated, $english, $date);
            }
        }

        foreach ($this->getShortMonthTranslationMap() as $english => $translated) {
            if (false !== strpos($date, $translated)) {
                $date = str_replace($translated, $english, $date);
            }
        }

        return $date;
    }