<commit_before>/*******************************************************************************
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package org.eclipse.mylyn.internal.tasks.core;

import java.text.DateFormat;
import java.util.Calendar;

import org.eclipse.core.runtime.Assert;

/**
 * @author <NAME>
 * @since 3.0
 */
public class DateRange implements Comparable<DateRange> {

	private static final long DAY = 1000 * 60 * 60 * 24;

	private static final String DESCRIPTION_PREVIOUS_WEEK = "Previous Week";

	private static final String DESCRIPTION_THIS_WEEK = "This Week";

	private static final String DESCRIPTION_NEXT_WEEK = "Next Week";

	private static final String DESCRIPTION_WEEK_AFTER_NEXT = "Two Weeks";

	private final Calendar startDate;

	private final Calendar endDate;

	/**
	 * create an instance of a date range that represents a finite point in time
	 */
	public DateRange(Calendar time) {
		startDate = time;
		endDate = time;
	}

	public DateRange(Calendar startDate, Calendar endDate) {
		Assert.isNotNull(startDate);
		Assert.isNotNull(endDate);
		this.startDate = startDate;
		this.endDate = endDate;
	}

	public boolean includes(DateRange range) {
		return (startDate.getTimeInMillis() <= range.getStartDate().getTimeInMillis())
				&& (endDate.getTimeInMillis() >= range.getEndDate().getTimeInMillis());
	}

	public boolean includes(Calendar cal) {
		return (startDate.getTimeInMillis() <= cal.getTimeInMillis())
				&& (endDate.getTimeInMillis() >= cal.getTimeInMillis());
	}

	public Calendar getStartDate() {
		return startDate;
	}

	public Calendar getEndDate() {
		return endDate;
	}

	/**
	 * TODO: Move into label provider
	 */
	@Override
	public String toString() {
		boolean isThisWeek = TaskActivityUtil.getCurrentWeek().includes(this);
		boolean isNextWeek = TaskActivityUtil.getNextWeek().includes(this);
		if (isDay() && (isThisWeek || isNextWeek)) {
			String day = "";
			switch (getStartDate().get(Calendar.DAY_OF_WEEK)) {<commit_msg>NEW - bug 243901: scheduled date is confusing on planning page when a day next week is selected https://bugs.eclipse.org/bugs/show_bug.cgi?id=243901<commit_after>/*******************************************************************************
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package org.eclipse.mylyn.internal.tasks.core;

import java.text.DateFormat;
import java.util.Calendar;

import org.eclipse.core.runtime.Assert;

/**
 * @author <NAME>
 * @since 3.0
 */
public class DateRange implements Comparable<DateRange> {

	private static final long DAY = 1000 * 60 * 60 * 24;

	private static final String DESCRIPTION_PREVIOUS_WEEK = "Previous Week";

	private static final String DESCRIPTION_THIS_WEEK = "This Week";

	private static final String DESCRIPTION_NEXT_WEEK = "Next Week";

	private static final String DESCRIPTION_WEEK_AFTER_NEXT = "Two Weeks";

	private final Calendar startDate;

	private final Calendar endDate;

	/**
	 * create an instance of a date range that represents a finite point in time
	 */
	public DateRange(Calendar time) {
		startDate = time;
		endDate = time;
	}

	public DateRange(Calendar startDate, Calendar endDate) {
		Assert.isNotNull(startDate);
		Assert.isNotNull(endDate);
		this.startDate = startDate;
		this.endDate = endDate;
	}

	public boolean includes(DateRange range) {
		return (startDate.getTimeInMillis() <= range.getStartDate().getTimeInMillis())
				&& (endDate.getTimeInMillis() >= range.getEndDate().getTimeInMillis());
	}

	public boolean includes(Calendar cal) {
		return (startDate.getTimeInMillis() <= cal.getTimeInMillis())
				&& (endDate.getTimeInMillis() >= cal.getTimeInMillis());
	}

	public Calendar getStartDate() {
		return startDate;
	}

	public Calendar getEndDate() {
		return endDate;
	}

	/**
	 * TODO: Move into label provider
	 */
	@Override
	public String toString() {
		boolean isThisWeek = TaskActivityUtil.getCurrentWeek().includes(this);
		Calendar endNextWeek = TaskActivityUtil.getCalendar();
		endNextWeek.add(Calendar.DAY_OF_YEAR, 7);
		boolean isNextWeek = TaskActivityUtil.getNextWeek().includes(this) && this.before(endNextWeek);
		if (isDay() && (isThisWeek || isNextWeek)) {
			String day = "";
			switch (getStartDate().get(Calendar.DAY_OF_WEEK)) {
{'fraction_non_alphanumeric': 0.16517857142857142, 'fraction_numerical': 0.012378246753246754, 'mean_word_length': 4.974545454545455, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '423253', 'n_tokens_mistral': 1563, 'n_tokens_neox': 1387, 'n_words': 393}