code: private Duration getRangeDuration(ProjectCalendar projectCalendar, TimescaleUnits rangeUnits, DateRange range, List<TimephasedWork> assignments, int startIndex)
     {
        Duration result;
  
        switch (rangeUnits)
        {
           case MINUTES:
           case HOURS:
           {
              result = getRangeDurationSubDay(projectCalendar, rangeUnits, range, assignments, startIndex);
              break;
           }
  
           default:
           {
              result = getRangeDurationWholeDay(projectCalendar, rangeUnits, range, assignments, startIndex);
              break;
           }
        }
  
        return result;
     }
docs: For a given date range, determine the duration of work, based on the
  timephased resource assignment data.
  
  @param projectCalendar calendar used for the resource assignment calendar
  @param rangeUnits timescale units
  @param range target date range
  @param assignments timephased resource assignments
  @param startIndex index at which to start searching through the timephased resource assignments
  @return work duration