@param $startDate 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
966817
public function getSlots(Request $request)
    {
        if (!empty($request->server->get('QUERY_STRING'))) {
            $data = $this->parseUrl($request->server->get('QUERY_STRING'));
            $authProviderId = $data['provider'];
            $providerRepo = new ProviderRepository();
            $provider = $providerRepo->get( $authProviderId );
            $data['provider'] = $provider->getEmrId();
            $this->repository->setConnection( $provider->getConnectionKey() );
            $collection = $this->repository->getSlots($data);
        } else {
            $data['startDate'] = date('Y-m-d');
            $collection = $this->repository->getSlots($data);
        }


        $bundle = new FHIRBundle;
        $bundleId = UUIDClass::v4();
        $currentDate = date('Y-m-d H:i:s');
        $count = 0;
        foreach ($collection as $slot) {
//            if ($slot instanceof AppointmentInterface) {
                $fhirAppointment = $this->interfaceToModel($slot);
                $resourceContainer = new FHIRResourceContainer;
                $resourceContainer->setAppointment($fhirAppointment);
                $bundleEntry = new FHIRBundleEntry();
                $fullUrl = new FHIRUri();
                $slotUrl = $request->url() . '/' . $bundleId;
                $fullUrl->setValue($slotUrl);
                $bundleEntry->setFullUrl($fullUrl);
                $bundleEntry->setResource($resourceContainer);
                $response = new FHIRBundleResponse;
                $location = new FHIRUri;
                $location->setValue('Slot/15/_history/1');
                $response->setLocation($location);
                $lastModified = new FHIRInstant();
                $lastModified->setValue($currentDate);
                $response->setLastModified($lastModified);
                $bundleEntry->setResponse($response);
                $bundle->addEntry($bundleEntry);

                $count++;
//            }
        }

        $meta = new FHIRMeta;
        $lastUpdated = new FHIRInstant();
        $lastUpdated->setValue($currentDate);
        $meta->setLastUpdated($lastUpdated);
        $bundle->setMeta($meta);

        $id = new FHIRId;
        $id->setValue($bundleId);
        $bundle->setId($id);

        $link = new FHIRBundleLink;
        $relation = new FHIRString;
        $relation->setValue('self');
        $link->relation = $relation;
        $fullUrl = $request->fullUrl();
        $url = new FHIRUri;
        $url->setValue($fullUrl);
        $link->url = $url;
        $bundle->addLink($link);

        $total = new FHIRUnsignedInt;
        $total->setValue($count);
        $bundle->total = $total;

        $type = new FHIRCode;
        $type->setValue('searchset');
        $bundle->type = $type;


        return $bundle;






        $output = array();
        if (!empty($slotBusy)) {
            foreach ( $slotBusy as $slot ) {
                $fhirSlot = $this->interfaceToModel($slot);
                $output[]= $fhirSlot;
            }
            return $output;
        } else {
            return new Response([
                'accountRegistered' => 0,
                'status'  => 'Fail',
                'message' => 'No slots found',
            ]);
        }


        //return $fhirSchedule;
    }
43285
private function getGroup($start = "WHERE",$table = NULL)
    {
        if(count($this->group))
        {
            $temp = [];
            foreach($this->group as $k=>$v)
                $temp[] = (!empty($table) ? $table."." : '')."`".$k."` = '".$v."'";
            return $start." ".implode(' AND ',$temp);
        }
        else
            return '';
    }
749696
public function weeks($startDay = 'Monday')
    {
        if (!isset($this->weeks[$startDay])) {
            $this->weeks[$startDay] = array();
            $keepWeeking = true;
            $weekPoint = clone $this->firstDay();

            while ($keepWeeking) {
                $candidateWeek = new Week($weekPoint, $startDay);
                if ($candidateWeek->weekStart() <= $this->lastDay()) {
                    $candidateWeek->setContainingMonth($this);
                    $this->weeks[$startDay][] = $candidateWeek;
                    $weekPoint->modify('+1 week');
                } else {
                    $keepWeeking = false;
                }
            }
        }
        return $this->weeks[$startDay];
    }
1261961
public function getInvoices(
        DateTime $startDate = null,
        DateTime $endDate = null,
        $max = self::MIRAKL_API_MAX_PAGINATE,
        $offset = self::MIRAKL_API_DEFAULT_OFFSET_PAGINATE,
        $shopId = null,
        $type = 'AUTO_INVOICE',
        $currency = null
    ) {
        $this->restClient->getConfig()->setPath(
            'request.options/headers/Authorization',
            $this->operatorKey
        );
        $command = $this->restClient->getCommand(
            'GetInvoices',
            array(
                'shopId' => $shopId,
                'startDate' => $startDate,
                'endDate' => $endDate,
                'type' => $type,
                'currency' => $currency,
                'max' => $max,
                'offset' => $offset
            )
        );
        $result = $this->restClient->execute($command);

        return $result;
    }
561305
public static function monthListBetweenDate($startDate, $endDate)
    {
		$output = [];
		$time   = strtotime($startDate);
		$last   = date('m-Y', strtotime($endDate));

		do {
		    $month = date('m-Y', $time);
		    $total = date('t', $time);

		    $output[] = [
		        'month' => $month,
		        'total' => $total,
		    ];

		    $time = strtotime('+1 month', $time);
		} while ($month != $last);
    }
1003417
protected function _dateDiff($start = null, $stop = null) {
		if ($start) {
			$endDate = $stop instanceof DateTime ? $stop : new DateTime($stop ? $stop : 'now');
			$startDate = $start instanceof DateTime ? $start : new DateTime($start);
			$diff = $startDate->diff($endDate)->format(Configure::read('Task.dateDiffFormat'));
			return $this->_isCli ? $diff : $this->Html->tag('span', $diff);
		} else {
			return $this->_none();
		}
	}
593443
protected function _date($date = null) {
		if ($date === null || !$date instanceof \DateTimeInterface) {
			return '';
		}
		$datePieces = [];
		$datePieces[] = $date->format('Y');
		// JavaScript uses 0-indexed months, so we need to subtract 1 month from PHP's output
		$datePieces[] = (int)($date->format('m')) - 1;
		$datePieces[] = (int)$date->format('d');
		$datePieces[] = (int)$date->format('H');
		$datePieces[] = (int)$date->format('i');
		$datePieces[] = (int)$date->format('s');

		return 'new Date(' . implode(', ', $datePieces) . ')';
	}
451353
public function getTopBrowsersForPeriod($startDate, $endDate, $maxResults)
    {
        $browserData = [];
        $answer = $this->performQuery($startDate, $endDate, 'ga:sessions', ['dimensions' => 'ga:browser', 'sort' => '-ga:sessions']);

        if (is_null($answer->rows)) {
            return new Collection([]);
        }

        foreach ($answer->rows as $browserRow) {
            $browserData[] = ['browser' => $browserRow[0], 'sessions' => $browserRow[1]];
        }

        $browserCollection = new Collection(array_slice($browserData, 0, $maxResults - 1));

        if (count($browserData) > $maxResults) {
            $otherBrowsers = new Collection(array_slice($browserData, $maxResults - 1));
            $otherBrowsersCount = array_sum($otherBrowsers->lists('sessions'));

            $browserCollection->put(null, ['browser' => 'other', 'sessions' => $otherBrowsersCount]);
        }

        return $browserCollection;
    }
894252
public function during($startDate, $endDate)
    {
        $validationResult = QueryValidator::validateCustomDateRange(
            $startDate,
            $endDate
        );
        if ($validationResult->isFailed()) {
            throw new InvalidArgumentException('The start or end date is' .
                ' invalid. Validation fail reasons: ' .
                $validationResult->getFailReason());
        }

        $this->duringStartDate = $startDate;
        $this->duringEndDate = $endDate;
    }
484148
public function setStartDate($startDate): void
    {
        if (is_string($startDate)) {
            $startDate = new Time($startDate);
        }

        $this->startDate = $startDate;
    }
710506
public function visitsByPeriod($startDate, $endDate, GetVisitByPeriod $getVisitByPeriod)
    {
        $startDate = Carbon::createFromFormat('Y-m-d', $startDate);
        $endDate = Carbon::createFromFormat('Y-m-d', $endDate);

        return $getVisitByPeriod->fire($startDate, $endDate);
    }
898504
public static function getFacilityCheckIns($memberId, $startDate, $endDate) {
    return \Drupal::entityQuery('openy_campaign_member_checkin')
      ->condition('member', $memberId)
      ->condition('date', $startDate->format('U'), '>=')
      ->condition('date', $endDate->format('U'), '<')
      ->execute();
  }
1203673
static public function getPeriode($startDate, $endDate = null, $nbMoisGlissant = false)
    {
        $dtStart = Datetime::getInstance();
        $dtEnd = Datetime::getInstance();
        
        $dtStart->set_date($startDate);
        $dtEnd->set_date(is_null($endDate) ? $startDate : $endDate);
        
        /*
         * Test si mois glissant
         */
        if ($dtStart->equals($dtEnd) === 0 && $nbMoisGlissant) {
            $dtStart->sub_month($nbMoisGlissant - 1);
        }
        
        if ($dtStart->equals($dtEnd) === 0) {
            $lib_periode = $dtStart->format('%B %Y');
            $shortlib_periode = $dtStart->format('%b %Y');
        }
        else {
            $lib_periode = $dtStart->format('%B %Y') . ' - ' . $dtEnd->format('%B %Y');
            $shortlib_periode = $dtStart->format('%b %Y') . ' - ' . $dtEnd->format('%b %Y');
        }
        
        $result = [
            'lib'      => $lib_periode,
            'shortlib' => $shortlib_periode,
            'start'    => $dtStart,
            'end'      => $dtEnd,
        ];
        
        return $result;
    }
511351
public function getStartTimes($starttime = 0, $endtime = 0, $tz = null) {
		if (!Util::isValidTimezone($tz)) {
			$tz = Util::getClientTimezone();
		}

		if (!$this->isRecurring()) {
			return array($this->getStartTimestamp());
		}

		$start_times = array();

		$test_day = ($this->getStartTimestamp() > $starttime) ? $this->getStartTimestamp() : $starttime;

		// iterate through each day of our range and see if this event shows up on any of those days
		while ($test_day < $endtime) {

			$shows = false;

			$offset_on_test_day = Util::getOffset($test_day, Util::UTC, $this->getTimezone());

			// next increment
			$next_test_day = $test_day + Util::SECONDS_IN_A_DAY;

			// event has no more occurrences after this day
			if ($this->repeat_end_timestamp && $this->repeat_end_timestamp < $test_day) {
				break;
			}

			switch ($this->repeat_frequency) {
				case Util::FREQUENCY_DAILY:
					$shows = true;
					break;

				case Util::FREQUENCY_WEEKDAY:
					$repeat_weekly_days = array(Util::SATURDAY, Util::SUNDAY);
					foreach ($repeat_weekly_days as $key => $day) {
						$repeat_weekly_days[$key] = Util::getDayOfWeek(strtotime($day, $test_day) - $offset_on_test_day);
					}
					$D = Util::getDayOfWeek($test_day);
					$shows = !in_array($D, $repeat_weekly_days);
					break;

				case Util::FREQUENCY_WEEKDAY_ODD:
					$repeat_weekly_days = array(Util::MONDAY, Util::WEDNESDAY, Util::FRIDAY);
					foreach ($repeat_weekly_days as $key => $day) {
						$repeat_weekly_days[$key] = Util::getDayOfWeek(strtotime($day, $test_day) - $offset_on_test_day);
					}
					$D = Util::getDayOfWeek($test_day);
					$shows = in_array($D, $repeat_weekly_days);
					break;

				case Util::FREQUENCY_WEEKDAY_EVEN:
					$repeat_weekly_days = array(Util::TUESDAY, Util::THURSDAY);
					foreach ($repeat_weekly_days as $key => $day) {
						$repeat_weekly_days[$key] = Util::getDayOfWeek(strtotime($day, $test_day) - $offset_on_test_day);
					}
					$D = Util::getDayOfWeek($test_day);
					$shows = in_array($D, $repeat_weekly_days);
					break;

				case Util::FREQUENCY_WEEKLY:
					$repeat_weekly_days = $this->repeat_weekly_days;
					if (!$repeat_weekly_days) {
						$repeat_weekly_days = Util::getDayOfWeek($this->getStartTimestamp());
					}
					if (!is_array($repeat_weekly_days)) {
						$repeat_weekly_days = array($repeat_weekly_days);
					}
					$D = Util::getDayOfWeek($test_day);
					foreach ($repeat_weekly_days as $key => $day) {
						// Monday in Sydney can still be Sunday at UTC
						$repeat_weekly_days[$key] = Util::getDayOfWeek(strtotime($day, $test_day) - $offset_on_test_day);
					}
					$shows = in_array($D, $repeat_weekly_days);
					break;

				case Util::FREQUENCY_MONTHLY:
					if ($this->repeat_monthly_by == Util::REPEAT_MONTHLY_BY_DAY_OF_WEEK) {
						$shows = Util::isOnSameWeekDayOfMonth($test_day, $this->getStartTimestamp());
						if ($shows) {
							// we can skip 4 weeks
							$next_test_day = strtotime('+28 days', $test_day);
						}
					} else {
						$shows = Util::isOnSameDayOfMonth($test_day, $this->getStartTimestamp());
						if ($shows) {
							// we can skip a month
							$next_test_day = strtotime('+1 month', $test_day);
						}
					}
					break;

				case Util::FREQUENCY_YEARLY:
					$shows = Util::isOnSameDayOfYear($test_day, $this->getStartTimestamp());
					if ($shows) {
						// we can skip a year
						$next_test_day = strtotime('+1 year', $test_day);
					}
					break;
			}

			if ($shows) {
				$occurrence = (int) Util::getTimeOfDay($this->getStartTimestamp(), $test_day);
				if ($occurrence >= $starttime && $occurrence <= $endtime) {
					// events may show on a start or end day, but not fall in the time range
					array_push($start_times, $occurrence);
				}
			}

			$test_day = $next_test_day;
		}

		$cancelled = $this->cancelled_instance;
		if (!$cancelled) {
			$cancelled = array();
		}
		if (!is_array($cancelled)) {
			$cancelled = array($cancelled);
		}

		return array_diff($start_times, $cancelled);
	}
761497
public function setStartDate($date)
    {
        $date = AnDomainAttributeDate::getInstance()->setDate($date);
        $this->set('startDate', $date);

        return $this;
    }
1267950
public function getAllEvents($starttime = null, $endtime = null) {

		if (is_null($starttime)) {
			$starttime = time();
		}
		if (is_null($endtime)) {
			$endtime = strtotime('+1 year', $starttime);
		}

		$starttime = sanitize_int($starttime);
		$endtime = sanitize_int($endtime);
		$relationship_name = sanitize_string(self::EVENT_CALENDAR_RELATIONSHIP);

		$dbprefix = elgg_get_config('dbprefix');

		$mds_name = elgg_get_metastring_id('start_timestamp');
		$mdre_name = elgg_get_metastring_id('repeat_end_timestamp');

		$options = array(
			'type' => 'object',
			'subtype' => Event::SUBTYPE,
			'joins' => array(
				"JOIN {$dbprefix}entity_relationships er ON er.guid_one = e.guid", // calendar relationship
				"JOIN {$dbprefix}metadata mds ON mds.entity_guid = e.guid", // start time metadata
				"JOIN {$dbprefix}metastrings mss ON mss.id = mds.value_id", // start time metastring
				"JOIN {$dbprefix}metadata mdre ON mdre.entity_guid = e.guid", // repeat end time metadata
				"JOIN {$dbprefix}metastrings msre ON msre.id = mdre.value_id" // repeat end time metastring
			),
			'wheres' => array(
				"er.guid_two = {$this->guid} AND er.relationship = '{$relationship_name}'",
				"mds.name_id = {$mds_name}",
				"mdre.name_id = {$mdre_name}",
				// event start is before our endtime AND (repeat end is after starttime, or there is no repeat end)
				"((CAST(mss.string AS SIGNED) < {$endtime}) AND (CAST(msre.string AS SIGNED) > {$starttime} OR CAST(msre.string AS SIGNED) = 0))"
			),
			'limit' => false
		);

		return new ElggBatch('elgg_get_entities', $options);
	}
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 );
	}