private void validateSameDay ( ProjectCalendar calendar , LinkedList < TimephasedWork > list ) { for ( TimephasedWork assignment : list ) { Date assignmentStart = assignment . getStart ( ) ; Date calendarStartTime = calendar . getStartTime ( assignmentStart ) ; Date assignmentStartTime = DateHelper . getCanonicalTime ( assignmentStart ) ; Date assignmentFinish = assignment . getFinish ( ) ; Date calendarFinishTime = calendar . getFinishTime ( assignmentFinish ) ; Date assignmentFinishTime = DateHelper . getCanonicalTime ( assignmentFinish ) ; double totalWork = assignment . getTotalAmount ( ) . getDuration ( ) ; if ( assignmentStartTime != null && calendarStartTime != null ) { if ( ( totalWork == 0 && assignmentStartTime . getTime ( ) != calendarStartTime . getTime ( ) ) || ( assignmentStartTime . getTime ( ) < calendarStartTime . getTime ( ) ) ) { assignmentStart = DateHelper . setTime ( assignmentStart , calendarStartTime ) ; assignment . setStart ( assignmentStart ) ; } } if ( assignmentFinishTime != null && calendarFinishTime != null ) { if ( ( totalWork == 0 && assignmentFinishTime . getTime ( ) != calendarFinishTime . getTime ( ) ) || ( assignmentFinishTime . getTime ( ) > calendarFinishTime . getTime ( ) ) ) { assignmentFinish = DateHelper . setTime ( assignmentFinish , calendarFinishTime ) ; assignment . setFinish ( assignmentFinish ) ; } } } }
Ensures that the start and end dates for ranges fit within the working times for a given day .