/*[deutsch]
<p>Erzeugt eine neue Regel zur Zerlegung eines Tages in einen oder mehrere Tagesabschnitte. </p>

@return  DayPartitionRule
324817
public DayPartitionRule build() {

        final Map<Weekday, List<ChronoInterval<PlainTime>>> wRules = new EnumMap<>(this.weekdayRules);
        final Map<PlainDate, List<ChronoInterval<PlainTime>>> eRules = new HashMap<>(this.exceptionRules);
        final Set<PlainDate> invalid = new HashSet<>(this.exclusions);

        return new DayPartitionRule() {
            @Override
            public List<ChronoInterval<PlainTime>> getPartitions(PlainDate date) {
                if (!this.isExcluded(date) && activeFilter.test(date)) {
                    List<ChronoInterval<PlainTime>> partitions = eRules.get(date);
                    if (partitions == null) {
                        partitions = wRules.get(date.getDayOfWeek());
                    }
                    if (partitions != null) {
                        return Collections.unmodifiableList(partitions);
                    }
                }
                return Collections.emptyList();
            }
            @Override
            public boolean isExcluded(PlainDate date) {
                return invalid.contains(date);
            }
        };

    }
1049631
public static function thisWeek()
    {
        $start = CarbonDate::today();
        $end = CarbonDate::tomorrow();
        if ($start->dayOfWeek !== CarbonDate::MONDAY) {
            $start->modify('last monday');
        }

        return new static($start, $end);
    }
876576
public static Long getSunday() {
		cal.setTimeInMillis(System.currentTimeMillis());
		cal.add(Calendar.DATE, -dayOfWeek() + 7);
		return cal.getTimeInMillis();
	}
182625
public function days()
    {
        if (!isset($this->days)) {
            $clonedStart = clone $this->weekStart;
            $this->days = array();
            for ($i = 0; $i < 7; $i ++) {
                $thisDay = new Day($clonedStart);

                if (
                    $this->containingMonth
                    && $this->containingMonth->firstDay()->format('m') != $clonedStart->format('m')
                ) {
                    $thisDay->setIsOverflow(true);
                }

                $this->days[] = $thisDay;
                $clonedStart->modify('+1 day');
            }
        }
        return $this->days;
    }
777149
@Override
    public CronDefinitionBuilder and() {
        final boolean zeroInRange = constraints.createConstraintsInstance().isInRange(0);
        cronDefinitionBuilder
                .register(new DayOfWeekFieldDefinition(fieldName, constraints.createConstraintsInstance(), optional, new WeekDay(mondayDoWValue, zeroInRange)));
        return cronDefinitionBuilder;
    }
1071930
private I_CmsListDateRestriction parseFromToday(CmsXmlContentValueLocation dateRestriction) {

        CmsXmlContentValueLocation location = dateRestriction.getSubValue(N_FROM_TODAY);
        if (location == null) {
            return null;
        }
        CmsXmlContentValueLocation countLoc = location.getSubValue(N_COUNT);
        CmsXmlContentValueLocation unitLoc = location.getSubValue(N_UNIT);
        CmsXmlContentValueLocation directionLoc = location.getSubValue(N_DIRECTION);

        TimeDirection direction = parseDirection(directionLoc);
        Integer count = parsePositiveNumber(countLoc);
        TimeUnit unit = parseUnit(unitLoc);
        if (count == null) {
            return null;
        }
        return new CmsListDateFromTodayRestriction(count.intValue(), unit, direction);
    }
252518
public function getDateValidationRule()
    {
        if ($this->isDateOrTime()) {
            if (!empty($this->dateFormat)) {
                return sprintf('date_format:%s', $this->dateFormat);
            }

            return 'date';
        }

        return null;
    }
1241084
@Nullable
    public Date getGpsDate()
    {
        String date = getString(TAG_DATE_STAMP);
        Rational[] timeComponents = getRationalArray(TAG_TIME_STAMP);

        // Make sure we have the required values
        if (date == null)
            return null;
        if (timeComponents == null || timeComponents.length != 3)
            return null;

        String dateTime = String.format(Locale.US, "%s %02d:%02d:%02.3f UTC",
            date, timeComponents[0].intValue(), timeComponents[1].intValue(), timeComponents[2].doubleValue());
        try {
            DateFormat parser = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss.S z");
            return parser.parse(dateTime);
        } catch (ParseException e) {
            return null;
        }
    }
853036
protected List<Rule> parsePattern() {
		final DateFormatSymbols symbols = new DateFormatSymbols(locale);
		final List<Rule> rules = new ArrayList<>();

		final String[] ERAs = symbols.getEras();
		final String[] months = symbols.getMonths();
		final String[] shortMonths = symbols.getShortMonths();
		final String[] weekdays = symbols.getWeekdays();
		final String[] shortWeekdays = symbols.getShortWeekdays();
		final String[] AmPmStrings = symbols.getAmPmStrings();

		final int length = pattern.length();
		final int[] indexRef = new int[1];

		for (int i = 0; i < length; i++) {
			indexRef[0] = i;
			final String token = parseToken(pattern, indexRef);
			i = indexRef[0];

			final int tokenLen = token.length();
			if (tokenLen == 0) {
				break;
			}

			Rule rule;
			final char c = token.charAt(0);

			switch (c) {
				case 'G': // era designator (text)
					rule = new TextField(Calendar.ERA, ERAs);
					break;
				case 'y': // year (number)
				case 'Y': // week year
					if (tokenLen == 2) {
						rule = TwoDigitYearField.INSTANCE;
					} else {
						rule = selectNumberRule(Calendar.YEAR, tokenLen < 4 ? 4 : tokenLen);
					}
					if (c == 'Y') {
						rule = new WeekYear((NumberRule) rule);
					}
					break;
				case 'M': // month in year (text and number)
					if (tokenLen >= 4) {
						rule = new TextField(Calendar.MONTH, months);
					} else if (tokenLen == 3) {
						rule = new TextField(Calendar.MONTH, shortMonths);
					} else if (tokenLen == 2) {
						rule = TwoDigitMonthField.INSTANCE;
					} else {
						rule = UnpaddedMonthField.INSTANCE;
					}
					break;
				case 'd': // day in month (number)
					rule = selectNumberRule(Calendar.DAY_OF_MONTH, tokenLen);
					break;
				case 'h': // hour in am/pm (number, 1..12)
					rule = new TwelveHourField(selectNumberRule(Calendar.HOUR, tokenLen));
					break;
				case 'H': // hour in day (number, 0..23)
					rule = selectNumberRule(Calendar.HOUR_OF_DAY, tokenLen);
					break;
				case 'm': // minute in hour (number)
					rule = selectNumberRule(Calendar.MINUTE, tokenLen);
					break;
				case 's': // second in minute (number)
					rule = selectNumberRule(Calendar.SECOND, tokenLen);
					break;
				case 'S': // millisecond (number)
					rule = selectNumberRule(Calendar.MILLISECOND, tokenLen);
					break;
				case 'E': // day in week (text)
					rule = new TextField(Calendar.DAY_OF_WEEK, tokenLen < 4 ? shortWeekdays : weekdays);
					break;
				case 'u': // day in week (number)
					rule = new DayInWeekField(selectNumberRule(Calendar.DAY_OF_WEEK, tokenLen));
					break;
				case 'D': // day in year (number)
					rule = selectNumberRule(Calendar.DAY_OF_YEAR, tokenLen);
					break;
				case 'F': // day of week in month (number)
					rule = selectNumberRule(Calendar.DAY_OF_WEEK_IN_MONTH, tokenLen);
					break;
				case 'w': // week in year (number)
					rule = selectNumberRule(Calendar.WEEK_OF_YEAR, tokenLen);
					break;
				case 'W': // week in month (number)
					rule = selectNumberRule(Calendar.WEEK_OF_MONTH, tokenLen);
					break;
				case 'a': // am/pm marker (text)
					rule = new TextField(Calendar.AM_PM, AmPmStrings);
					break;
				case 'k': // hour in day (1..24)
					rule = new TwentyFourHourField(selectNumberRule(Calendar.HOUR_OF_DAY, tokenLen));
					break;
				case 'K': // hour in am/pm (0..11)
					rule = selectNumberRule(Calendar.HOUR, tokenLen);
					break;
				case 'X': // ISO 8601
					rule = Iso8601_Rule.getRule(tokenLen);
					break;
				case 'z': // time zone (text)
					if (tokenLen >= 4) {
						rule = new TimeZoneNameRule(timeZone, locale, TimeZone.LONG);
					} else {
						rule = new TimeZoneNameRule(timeZone, locale, TimeZone.SHORT);
					}
					break;
				case 'Z': // time zone (value)
					if (tokenLen == 1) {
						rule = TimeZoneNumberRule.INSTANCE_NO_COLON;
					} else if (tokenLen == 2) {
						rule = Iso8601_Rule.ISO8601_HOURS_COLON_MINUTES;
					} else {
						rule = TimeZoneNumberRule.INSTANCE_COLON;
					}
					break;
				case '\'': // literal text
					final String sub = token.substring(1);
					if (sub.length() == 1) {
						rule = new CharacterLiteral(sub.charAt(0));
					} else {
						rule = new StringLiteral(sub);
					}
					break;
				default:
					throw new IllegalArgumentException("Illegal pattern component: " + token);
			}

			rules.add(rule);
		}

		return rules;
	}
1322967
public function getAsRule(): Rule
    {
        return new Rule(
            $this->subject,
            array_merge($this->passed, $this->further),
            $this->eof,
            $this->tag
        );
    }
1221995
def make_eventrule(date_rule, time_rule, cal, half_days=True):
    

    # Insert the calendar in to the individual rules
    date_rule.cal = cal
    time_rule.cal = cal

    if half_days:
        inner_rule = date_rule & time_rule
    else:
        nhd_rule = NotHalfDay()
        nhd_rule.cal = cal
        inner_rule = date_rule & time_rule & nhd_rule

    return OncePerDay(rule=inner_rule)
191497
public static function daysAgo()
    {
        return self::getOrCreate('days-ago', function () {
            return RangeRule::createForNegativeValues(Unit::DAY, Unit::DAY * 7 - 1, [Results::class, 'calculateDaysAgo']);
        });
    }
464381
public java.util.Map<String, String> getMonday() {
        if (monday == null) {
            monday = new com.amazonaws.internal.SdkInternalMap<String, String>();
        }
        return monday;
    }
24404
private static TimeZoneRule createRuleByRDATE(String tzname,
            int rawOffset, int dstSavings, long start, List<String> dates, int fromOffset) {
        // Create an array of transition times
        long[] times;
        if (dates == null || dates.size() == 0) {
            // When no RDATE line is provided, use start (DTSTART)
            // as the transition time
            times = new long[1];
            times[0] = start;
        } else {
            times = new long[dates.size()];
            int idx = 0;
            try {
                for (String date : dates) {
                    times[idx++] = parseDateTimeString(date, fromOffset);
                }
            } catch (IllegalArgumentException iae) {
                return null;
            }
        }
        return new TimeArrayTimeZoneRule(tzname, rawOffset, dstSavings, times, DateTimeRule.UTC_TIME);
    }
146378
public function GroupByClause()
    {
        $this->match(Lexer::T_GROUP);
        $this->match(Lexer::T_BY);

        $groupByItems = [$this->GroupByItem()];

        while ($this->lexer->isNextToken(Lexer::T_COMMA)) {
            $this->match(Lexer::T_COMMA);

            $groupByItems[] = $this->GroupByItem();
        }

        return new AST\GroupByClause($groupByItems);
    }
711905
public function getPreconditionRule(): Rule
    {
        // we combine each topics with an AND and a OR inside of their rules.
        // so all topics have to match, and one topic needs at least 1 rule that matches.
        $requirements = new AndRule(
            []
        );

        $personasFound = false;
        $personaOR = new OrRule();

        // check if we have persona rules and add them
        // to our persona OR as a separate OR rule with all configured rules
        if ($this->getPersonaRules() !== null && count($this->getPersonaRules()->getElements()) > 0) {
            $personaRuleOR = new OrRule();

            /** @var RuleEntity $ruleEntity */
            foreach ($this->getPersonaRules()->getElements() as $ruleEntity) {
                // add rule our rule and also make sure
                // we know that at least a persona exists.
                $personaRuleOR->addRule($ruleEntity->getPayload());
                $personasFound = true;
            }

            $personaOR->addRule($personaRuleOR);
        }

        // check if we have customers.
        // if so, create customer rules for it and add that also as
        // a separate OR condition to our main persona rule
        if ($this->getPersonaCustomers() !== null) {
            $personaCustomerOR = new OrRule();

            /* @var CustomerEntity $ruleEntity */
            foreach ($this->getPersonaCustomers()->getElements() as $customer) {
                // build our new rule for this
                // customer and his/her customer number
                $custRule = new CustomerNumberRule();
                $custRule->assign(['numbers' => [$customer->getCustomerNumber()], 'operator' => CustomerNumberRule::OPERATOR_EQ]);

                // add rule for customer and make sure
                // we know that at least a persona exists.
                $personaCustomerOR->addRule($custRule);
                $personasFound = true;
            }

            $personaOR->addRule($personaCustomerOR);
        }

        // if we have found any persona rule
        // or customer, then add our main persona rule
        if ($personasFound) {
            $requirements->addRule($personaOR);
        }

        if ($this->getCartRules() !== null && count($this->getCartRules()->getElements()) > 0) {
            $cartOR = new OrRule([]);

            /** @var RuleEntity $ruleEntity */
            foreach ($this->getCartRules()->getElements() as $ruleEntity) {
                $cartOR->addRule($ruleEntity->getPayload());
            }

            $requirements->addRule($cartOR);
        }

        if ($this->getOrderRules() !== null && count($this->getOrderRules()->getElements()) > 0) {
            $orderOR = new OrRule([]);

            /** @var RuleEntity $ruleEntity */
            foreach ($this->getOrderRules()->getElements() as $ruleEntity) {
                $orderOR->addRule($ruleEntity->getPayload());
            }

            $requirements->addRule($orderOR);
        }

        return $requirements;
    }
367930
public java.util.Map<String, String> getSaturday() {
        if (saturday == null) {
            saturday = new com.amazonaws.internal.SdkInternalMap<String, String>();
        }
        return saturday;
    }