All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.future.earth.gwt.client.date.week.DayHelper Maven / Gradle / Ivy

There is a newer version: 3.3
Show newest version
package eu.future.earth.gwt.client.date.week;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import eu.future.earth.gwt.client.date.DateRenderer;
import eu.future.earth.gwt.client.date.DateUtils;

public class DayHelper {

	public Calendar getTheDay() {
		return theDay;
	}

	public void setTheDay(Calendar theDay) {
		this.theDay = theDay;
	}

	public DayHelper() {
		super();
	}

	public DateRenderer getRenderer() {
		return renderer;
	}

	public void setRenderer(DateRenderer renderer) {
		this.renderer = renderer;
	}

	public DayHelper(Calendar theDay, DateRenderer renderer) {
		super();
		this.theDay = theDay;
		this.renderer = renderer;
	}

	private Calendar theDay = new GregorianCalendar();

	private DateRenderer renderer = null;

	public boolean isDay(T newEvent) {
		if (DateUtils.isSameDay(theDay.getTime(), renderer.getStartTime(newEvent))) {
			return true;
		} else {
			Date endTime = renderer.getEndTime(newEvent);
			if (endTime != null) {
				if (DateUtils.isSameDay(theDay.getTime(), endTime) && DateUtils.zeroMinutes(endTime)) {
					return false;
				}
				if (DateUtils.isSameDay(theDay.getTime(), endTime)) {
					return true;
				} else {
					// It can overlap the date
					if (theDay.getTime().before(endTime) && theDay.getTime().after(renderer.getStartTime(newEvent))) {
						return true;
					} else {
						return false;
					}
				}
			} else {
				return false;
			}
		}

	}

	public Date getTime() {
		return theDay.getTime();
	}

	public void setTime(Date time) {
		theDay.setTime(time);
	}

	public void setFirstDayOfWeek(int firstDayOfWeek) {
		theDay.setFirstDayOfWeek(firstDayOfWeek);

	}

	public int get(int field) {
		return theDay.get(field);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy