74 lines
1.2 KiB
Java
74 lines
1.2 KiB
Java
package org.hwo.pulscounter.elements;
|
|
|
|
import org.hwo.datetime.Date;
|
|
import org.hwo.datetime.TimeOfDay;
|
|
import org.hwo.datetime.DateTime;
|
|
|
|
|
|
public class WorkShift {
|
|
|
|
private String name;
|
|
private String comment;
|
|
|
|
private TimeOfDay begins;
|
|
private TimeOfDay ends;
|
|
|
|
public WorkShift(){
|
|
this.name = "";
|
|
this.comment = "";
|
|
this.begins = new TimeOfDay();
|
|
this.ends = new TimeOfDay();
|
|
}
|
|
|
|
public boolean isOverMidnight(){
|
|
return ends.isEarlierThan(begins);
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public String getComment() {
|
|
return comment;
|
|
}
|
|
public void setComment(String comment) {
|
|
this.comment = comment;
|
|
}
|
|
|
|
public TimeOfDay getBegins() {
|
|
return begins;
|
|
}
|
|
public void setBegins(TimeOfDay begins) {
|
|
this.begins = begins;
|
|
}
|
|
|
|
public TimeOfDay getEnds() {
|
|
return ends;
|
|
}
|
|
public void setEnds(TimeOfDay ends) {
|
|
this.ends = ends;
|
|
}
|
|
|
|
public DateTime getShiftBegins(Date date){
|
|
DateTime dt = new DateTime(date, begins);
|
|
return dt;
|
|
}
|
|
|
|
public DateTime getShiftEnds(Date date){
|
|
DateTime dt = new DateTime(date, ends);
|
|
if (isOverMidnight()){
|
|
dt.getDate().addDays(1);
|
|
}
|
|
return dt;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return this.name;
|
|
}
|
|
|
|
}
|