Get the period to be used for this fact.  If a period rule does not exist, use the formula source value
@param array $source
@param array $evaluationResult
@param \XBRL_Log $log
@return array|NULL
195196
private function getPeriodAspectValue( $source, $evaluationResult, $log )
	{
		// Get the period name from the source
		if ( is_null( $this->periodRule ) )
		{
			$context = $this->getContextForSource( $source, $evaluationResult, ASPECT_PERIOD, $log, $contextRef );
			if ( ! $context || ! isset( $context['period'] ) ) return null;

			// TODO What is in the $context array
			return $context['period'];
		}
		else
		{
			/**
			 *
			 * @var Period $period
			 */
			$period = Period::fromArray( $this->periodRule );
			// This function will throw an exception if there is a problem so there is no return value to check
			$this->checkSAVConflicts( $period->source, ASPECT_PERIOD, $evaluationResult, $log );
			return $period->getValue( $this, $evaluationResult, $log );
		}
	}
199859
def calculate(self, variable_name, period, **parameters):
        
        population = self.get_variable_population(variable_name)
        holder = population.get_holder(variable_name)
        variable = self.tax_benefit_system.get_variable(variable_name, check_existence = True)

        if period is not None and not isinstance(period, periods.Period):
            period = periods.period(period)

        if self.trace:
            self.tracer.record_calculation_start(variable.name, period, **parameters)

        self._check_period_consistency(period, variable)

        # First look for a value already cached
        cached_array = holder.get_array(period)
        if cached_array is not None:
            if self.trace:
                self.tracer.record_calculation_end(variable.name, period, cached_array, **parameters)
            return cached_array

        array = None

        # First, try to run a formula
        try:
            self._check_for_cycle(variable, period)
            array = self._run_formula(variable, population, period)

            # If no result, use the default value and cache it
            if array is None:
                array = holder.default_array()

            array = self._cast_formula_result(array, variable)

            holder.put_in_cache(array, period)
        except SpiralError:
            array = holder.default_array()
        finally:
            if self.trace:
                self.tracer.record_calculation_end(variable.name, period, array, **parameters)
            self._clean_cycle_detection_data(variable.name)

        self.purge_cache_of_invalid_values()

        return array
407984
private function _addResultSuffix(\DateInterval $interval, $result)
    {
        return $interval->invert ? self::$PREFIX_IN."\xC2\xA0".$result : $result."\xC2\xA0".self::$SUFFIX_AGO;
    }
1054242
public function getHoursLoggedForLast($period, $project = null, $branches = null)
    {
        $endDate = date('m/d/Y');
        $startDate   = date_format(date_sub(date_create($endDate), date_interval_create_from_date_string($period)), 'm/d/Y');

        return $this->getHoursLoggedFor($startDate, $endDate, $project, $branches);
    }
78632
public function toQuery( $variableSet, $factVariableBinding )
	{
		// return null;
		$variable = $this->variable['originalPrefix']
			? "{$this->variable['originalPrefix']}:{$this->variable['name']}"
			: $this->variable['name'];

		if ( $this->boundary == "start" ||  $this->boundary == "end" )
		{
			return "(xfi:period(.)[ if (xfi:is-instant-period(.) and xfi:is-start-end-period(xfi:period(\$$variable))) then (xfi:period-instant(.) eq xfi:period-{$this->boundary}(xfi:period(\$$variable))) else fn:false() ])";
		}
		else
		{
			return "fn:false()";
		}
	}
274746
public function scopeActiveOn($query, $period)
    {
        return $query->whereHas('periods', function($query) use ($period){
            $query->where('academic_periods_id', $period);
        });
    }
57037
protected function getSourcesSearchPhrases($days = 30, $maxResult = 10)
    {
        list($startDate, $endDate) = $this->calculateDays($days);

        $this->getSourcesSearchPhrasesForPeriod($startDate, $endDate,
            $maxResult);
    }
271100
public function getAdditionalNamespaces( $variableSet, $evaluationResult )
	{
		$namespaces = array();

		foreach ( $this->multiplyBy as $numerator )
		{
			if ( ! isset( $numerator['measure'] ) || ! $numerator['measure'] ) continue;

			// This is an expression that needs evaluating
			$result = $this->evaluateXPath( $variableSet, "{$numerator['measure']}", $evaluationResult['vars'] );
			if ( $result instanceof XPath2Item )
			{
				$result = $result->getTypedValue();
			}
			// Should report an error here
			if ( ! $result instanceof QNameValue ) continue;
			$namespaces[ $result->Prefix ] = $result->NamespaceUri;
		}

		foreach ( $this->divideBy as $denominator )
		{
			if ( ! isset( $denominator['measure'] ) || ! $denominator['measure'] ) continue;

			// This is an expression that needs evaluating
			$result = $this->evaluateXPath( $variableSet, "{$denominator['measure']}", $evaluationResult['vars'] );
			if ( $result instanceof XPath2Item )
			{
				$result = $result->getTypedValue();
			}
			// Should report an error here
			if ( ! $result instanceof QNameValue ) continue;
			$namespaces[ $result->Prefix ] = $result->NamespaceUri;
		}

		return $namespaces;
	}
489469
public com.google.api.ads.admanager.axis.v201808.DateTime getEvaluationTime() {
        return evaluationTime;
    }
61541
public static function evaluatePolicySet(
        ContextInterface $context,
        int $match,
        array $encodedPolicySet,
        ?LoggerInterface $logger
    ): array {
        assert(Encoder::isPolicySet($encodedPolicySet));

        /** @see http://docs.oasis-open.org/xacml/3.0/xacml-3.0-core-spec-os-en.html #7.13 (table 6) */

        // Reminder on obligations and advice (from 7.18)
        //---------------------------------------------------------------------
        // no obligations or advice SHALL be returned to the PEP if the rule,
        // policies, or policy sets from which they are drawn are not evaluated,
        // or if their evaluated result is "Indeterminate" or "NotApplicable",
        // or if the decision resulting from evaluating the rule, policy,
        // or policy set does not match the decision resulting from evaluating
        // an enclosing policy set.

        $policySetName = null;
        if ($logger !== null) {
            $policySetName = Encoder::policySetName($encodedPolicySet);
            $matchName     = TargetMatchEnum::toString($match);
            $logger->debug("Policy set '$policySetName' evaluation started for match '$matchName'.");
        }

        if ($match === TargetMatchEnum::MATCH ||
            $match === TargetMatchEnum::NO_TARGET ||
            $match === TargetMatchEnum::INDETERMINATE
        ) {
            list ($evaluation, $obligations, $advice) = static::callPolicyAlgorithm(
                $context,
                Encoder::policiesAndSetsData(Encoder::policySetChildren($encodedPolicySet)),
                $logger
            );

            if ($match === TargetMatchEnum::INDETERMINATE) {
                // evaluate final result in accordance to table 7
                $correctedEvaluation = static::correctEvaluationOnIntermediateTarget($evaluation, $logger);
                $result = static::packEvaluationResult($correctedEvaluation);
            } else {
                $obligationsMap = Encoder::policySetObligations($encodedPolicySet);
                $adviceMap      = Encoder::policySetAdvice($encodedPolicySet);
                $result         = static::packEvaluationResult(
                    $evaluation,
                    static::mergeFulfilledObligations($obligations, $evaluation, $obligationsMap),
                    static::mergeAppliedAdvice($advice, $evaluation, $adviceMap)
                );
            }
        } else {
            assert($match === TargetMatchEnum::NOT_MATCH);
            $result = static::packEvaluationResult(EvaluationEnum::NOT_APPLICABLE);
        }

        $logger === null ?: $logger->debug("Policy set '$policySetName' evaluation ended.");

        return $result;
    }
110861
@Override
  public final Float evalFloatResult(
    final String pQuery, final String pColumnName) throws Exception {
    Float result = null;
    IRecordSet<RS> recordSet = null;
    try {
      recordSet = retrieveRecords(pQuery);
      if (recordSet.moveToFirst()) {
        result = recordSet.getFloat(pColumnName);
      }
    } finally {
      if (recordSet != null) {
        recordSet.close();
      }
    }
    return result;
  }
875544
public function getValue( $variableSet, $evaluationResult, $log )
	{
		// This is an error
		if ( ! isset( $variableSet->context ) ) return array();

		// Get context for this rule's source
		$sourceContext = $variableSet->getComponentForPath( $this->source, $variableSet->typedDimensionsComponentPath, 'typedMember', $evaluationResult, $this->aspectDimension, $log, $contextRef );
		$sourceContext = Dimension::contextToIndex( $sourceContext, false, $variableSet, $this->aspectDimension );

		// Get original context
		$context = $variableSet->context;

		if ( ! $variableSet->xbrlInstance->getNamespaceForPrefix( $this->dimension['originalPrefix'] ) )
		{
			$this->dimension['originalPrefix'] = $variableSet->xbrlInstance->getPrefixForNamespace( $this->dimension['namespace'] );
		}
		$dimensionQName = "{$this->dimension['originalPrefix']}:{$this->dimension['name']}";

		if ( $this->omit )
		{
			// Omit always applies to the default context
			unset( $context[ $dimensionQName ] );
		}
		else if ( $this->xpath )
		{
			$vars = $evaluationResult['vars'];
			$result = $this->evaluateXPath( $variableSet, $this->xpath, $vars );
			$error = false;
			if ( $result instanceof XPath2NodeIterator && $result->getCount() == 1 )
			{
				$result->MoveNext();
				$node = $result->getCurrent()->CloneInstance();
				$parent = $node->CloneInstance();
				$parent->MoveToParent();
				if ( $parent->getLocalName() == 'typedMember' && $parent->getNamespaceURI() == \XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLDI ] )
				{
					$valueElement = $node->getName();
					$member = $node->getValue();
					$context[ $dimensionQName ] = array( $valueElement => array( "<$valueElement>$member</$valueElement>" ) );
				}
				else
				{
					$error = true;
				}
			}
			else
			{
				$error = true;
			}
			if ( $error )
			{
				$log->formula_validation( "Typed dimension aspect rule", "The xpath references an node that does not define a typed dimension or returns an ambiguous result",
					array(
						'xpath' => $this->xpath,
						'dimension' => $dimensionQName,
						'error' => 'xbrlfe:wrongXpathResultForTypedDimensionRule'
					)
				);
			}
		}
		else if ( $this->dimension )
		{
			if ( $this->member )
			{
				if ( isset( $context[ $dimensionQName ] ) )
				{
					foreach ( $this->member as $memberElementKey => $names )
					{
						if ( isset( $context[ $dimensionQName ][ $memberElementKey ] ) )
						{
							foreach ( $names as $nameKey => $name )
							{
								$element = "<$memberElementKey>$name</$memberElementKey>";

								if ( ! in_array( $element, $context[ $dimensionQName ][ $memberElementKey ] ) )
								{
									$context[ $dimensionQName ][ $memberElementKey ][] = $element;
								}
							}
						}
						else
						{
							$context[ $dimensionQName ][ $memberElementKey ] = $names;
						}
					}
				}
				else
				{
					$context[ $dimensionQName ] = $this->member;
				}
			}
			else
			{
				// If there is no member, grab the member from the context if the dimension exists
				if ( isset( $sourceContext[ $dimensionQName ] ) )
				{
					$context[ $dimensionQName ] = $sourceContext[ $dimensionQName ];
				}
			}
		}
		// else if ( isset( $sourceContext[ $dimensionQName ] ) )
		// {
		// 	// Add any members from the source
		// 	$context[ $dimensionQName ] = $sourceContext[ $dimensionQName ];
		// }
		else
		{
			$log->formula_validation( "Typed dimension aspect rule", "A dimension is being added but there are no members",
				array(
					'dimension' => $dimensionQName,
					'error' => 'xbrlfe:missingSAVForExplicitDimensionRule'
				)
			);
		}

		return $context;
	}
664620
def eval(self, edate, etime):
        """"""
        if _debug: LocalScheduleInterpreter._debug("eval %r %r", edate, etime)

        # reference the schedule object
        sched_obj = self.sched_obj
        if _debug: LocalScheduleInterpreter._debug("    sched_obj: %r", sched_obj)

        # verify the date falls in the effective period
        if not match_date_range(edate, sched_obj.effectivePeriod):
            return None

        # the event priority is a list of values that are in effect for
        # exception schedules with the special event priority, see 135.1-2013
        # clause 7.3.2.23.10.3.8, Revision 4 Event Priority Test
        event_priority = [None] * 16

        next_day = (24, 0, 0, 0)
        next_transition_time = [None] * 16

        # check the exception schedule values
        if sched_obj.exceptionSchedule:
            for special_event in sched_obj.exceptionSchedule:
                if _debug: LocalScheduleInterpreter._debug("    - special_event: %r", special_event)

                # check the special event period
                special_event_period = special_event.period
                if special_event_period is None:
                    raise RuntimeError("special event period required")

                match = False
                calendar_entry = special_event_period.calendarEntry
                if calendar_entry:
                    if _debug: LocalScheduleInterpreter._debug("    - calendar_entry: %r", calendar_entry)
                    match = date_in_calendar_entry(edate, calendar_entry)
                else:
                    # get the calendar object from the application
                    calendar_object = sched_obj._app.get_object_id(special_event_period.calendarReference)
                    if not calendar_object:
                        raise RuntimeError("invalid calendar object reference")
                    if _debug: LocalScheduleInterpreter._debug("    - calendar_object: %r", calendar_object)

                    for calendar_entry in calendar_object.dateList:
                        if _debug: LocalScheduleInterpreter._debug("    - calendar_entry: %r", calendar_entry)
                        match = date_in_calendar_entry(edate, calendar_entry)
                        if match:
                            break

                # didn't match the period, try the next special event
                if not match:
                    if _debug: LocalScheduleInterpreter._debug("    - no matching calendar entry")
                    continue

                # event priority array index
                priority = special_event.eventPriority - 1
                if _debug: LocalScheduleInterpreter._debug("    - priority: %r", priority)

                # look for all of the possible times
                for time_value in special_event.listOfTimeValues:
                    tval = time_value.time
                    if tval <= etime:
                        if isinstance(time_value.value, Null):
                            if _debug: LocalScheduleInterpreter._debug("    - relinquish exception @ %r", tval)
                            event_priority[priority] = None
                            next_transition_time[priority] = None
                        else:
                            if _debug: LocalScheduleInterpreter._debug("    - consider exception @ %r", tval)
                            event_priority[priority] = time_value.value
                            next_transition_time[priority] = next_day
                    else:
                        next_transition_time[priority] = tval
                        break

        # assume the next transition will be at the start of the next day
        earliest_transition = next_day

        # check if any of the special events came up with something
        for priority_value, next_transition in zip(event_priority, next_transition_time):
            if next_transition is not None:
                earliest_transition = min(earliest_transition, next_transition)
            if priority_value is not None:
                if _debug: LocalScheduleInterpreter._debug("    - priority_value: %r", priority_value)
                return priority_value, earliest_transition

        # start out with the default
        daily_value = sched_obj.scheduleDefault

        # check the daily schedule
        if sched_obj.weeklySchedule:
            daily_schedule = sched_obj.weeklySchedule[edate[3]]
            if _debug: LocalScheduleInterpreter._debug("    - daily_schedule: %r", daily_schedule)

            # look for all of the possible times
            for time_value in daily_schedule.daySchedule:
                if _debug: LocalScheduleInterpreter._debug("    - time_value: %r", time_value)

                tval = time_value.time
                if tval <= etime:
                    if isinstance(time_value.value, Null):
                        if _debug: LocalScheduleInterpreter._debug("    - back to normal @ %r", tval)
                        daily_value = sched_obj.scheduleDefault
                    else:
                        if _debug: LocalScheduleInterpreter._debug("    - new value @ %r", tval)
                        daily_value = time_value.value
                else:
                    earliest_transition = min(earliest_transition, tval)
                    break

        # return what was matched, if anything
        return daily_value, earliest_transition
170278
protected function getForPeriod($key, \DatePeriod $period)
    {
        $ranges = $this->getRanges($period);

        if (count($ranges) > 0) {
            if (count($ranges) == 1 && !($ranges[0] instanceof DateRange)) {
                return new DateValue($ranges[0], $this->repository->getFor($key, $ranges[0]));
            }

            $values = array();

            /** @var \Krucas\Counter\DateRange $range */
            foreach ($ranges as $range) {
                $values[] = new RangeValue(
                    $range,
                    $this->repository->getForRange($key, $range->getStartDate(), $range->getEndDate())
                );
            }

            return $values;
        }

        return null;
    }
1154676
public function periodByStardDateByEndDateByFiscalYearAndByOrganizationId($startDate, $endDate, $fiscalYearId, $organizationId)
  {
    $Period = $this->Period->selectRaw('id, end_date, min(month) as month')
      ->where('start_date', '=', $startDate)
      ->where('end_date', '=', $endDate)
      ->where('fiscal_year_id', '=', $fiscalYearId)
      ->where('organization_id', '=', $organizationId)
      ->first();

    return $Period;
  }
864442
protected static function packEvaluationResult(int $evaluation, array $obligations = [], array $advice = []): array
    {
        return [
            self::EVALUATION_VALUE       => $evaluation,
            self::EVALUATION_OBLIGATIONS => $obligations,
            self::EVALUATION_ADVICE      => $advice,
        ];
    }
1239281
private function getUnitAspectValue( $source, $evaluationResult, $log )
	{
		// Get the unit from the source
		if ( is_null( $this->unitRule ) )
		{
			if ( ! $this->source )
			{
				return false;
			}

			$sourceFact = $this->getSourceFactWithErrorLogging( $source, $evaluationResult, ASPECT_UNIT, $log );
			$unitRef = FactValues::getUnitRef( $sourceFact );

			if ( ! $unitRef ) return null;

			// TODO What is in the $unit array
			$unit = $this->xbrlInstance->getUnit( $unitRef );
			return array( $unitRef => $unit );
		}
		else
		{
			/**
			 * @var Unit $unit
			 */
			$unit = Unit::fromArray( $this->unitRule );
			// This function will throw an exception if there is a problem so there is no return value to check
			$this->checkSAVConflicts( $unit->source, ASPECT_UNIT, $evaluationResult, $log );
			return $unit->getValue( $this, $evaluationResult, $log );
		}

	}