'Get the working intervals of the day based on calendar. This method
handle leaves that come directly from the leaves parameter or can be computed.
:param datetime start_dt: datetime object that is the beginning hours
for the working intervals computation; any
working interval beginning before start_dt
will be truncated. If not set, set to end_dt
or today() if no end_dt at 00.00.00.
:param datetime end_dt: datetime object that is the ending hour
for the working intervals computation; any
working interval ending after end_dt
will be truncated. If not set, set to start_dt()
at 23.59.59.
:param list leaves: a list of tuples(start_datetime, end_datetime) that
represent leaves.
:param boolean compute_leaves: if set and if leaves is None, compute the
leaves based on calendar and resource.
If leaves is None and compute_leaves false
no leaves are taken into account.
:param int resource_id: the id of the resource to take into account when
computing the leaves. If not set, only general
leaves are computed. If set, generic and
specific leaves are computed.
:param tuple default_interval: if no id, try to return a default working
day using default_interval[0] as beginning
hour, and default_interval[1] as ending hour.
Example: default_interval = (8, 16).
Otherwise, a void list of working intervals
is returned when id is None.
:return list intervals: a list of tuples (start_datetime, end_datetime)
of work intervals'

@api.multi
def get_working_intervals_of_day(self, start_dt=None, end_dt=None, leaves=None, compute_leaves=False, resource_id=None, default_interval=None):

    work_limits = []
    if ((start_dt is None) and (end_dt is not None)):
        start_dt = end_dt.replace(hour=0, minute=0, second=0, microsecond=0)
    elif (start_dt is None):
        start_dt = datetime.datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
    else:
        force_start_dt = self.env.context.get('force_start_dt')
        if (force_start_dt and (force_start_dt < start_dt)):
            work_limits.append((force_start_dt.replace(hour=0, minute=0, second=0, microsecond=0), force_start_dt))
        work_limits.append((start_dt.replace(hour=0, minute=0, second=0, microsecond=0), start_dt))
    if (end_dt is None):
        end_dt = start_dt.replace(hour=23, minute=59, second=59, microsecond=999999)
    else:
        work_limits.append((end_dt, end_dt.replace(hour=23, minute=59, second=59, microsecond=999999)))
    assert (start_dt.date() == end_dt.date()), 'get_working_intervals_of_day    is    restricted    to    one    day'
    intervals = []
    work_dt = start_dt.replace(hour=0, minute=0, second=0, microsecond=0)
    if (not self):
        working_interval = []
        if default_interval:
            working_interval = (start_dt.replace(hour=default_interval[0], minute=0, second=0, microsecond=0), start_dt.replace(hour=default_interval[1], minute=0, second=0, microsecond=0))
        intervals = self.interval_remove_leaves(working_interval, work_limits)
        return intervals
    working_intervals = []
    tz_info = fields.Datetime.context_timestamp(self, work_dt).tzinfo
    for calendar_working_day in self.get_attendances_for_weekday(start_dt):
        dt_f = (work_dt.replace(hour=0, minute=0, second=0, microsecond=0) + timedelta(seconds=(calendar_working_day.hour_from * 3600)))
        dt_t = (work_dt.replace(hour=0, minute=0, second=0, microsecond=0) + timedelta(seconds=(calendar_working_day.hour_to * 3600)))
        working_interval = (dt_f.replace(tzinfo=tz_info).astimezone(pytz.UTC).replace(tzinfo=None), dt_t.replace(tzinfo=tz_info).astimezone(pytz.UTC).replace(tzinfo=None), calendar_working_day.id)
        if self.env.context.get('force_start_dt'):
            for wi in self.interval_remove_leaves(working_interval, work_limits):
                if (wi[0] >= self.env.context['force_start_dt']):
                    working_intervals += [wi]
        else:
            working_intervals += self.interval_remove_leaves(working_interval, work_limits)
    if ((leaves is None) and compute_leaves):
        leaves = self.get_leave_intervals(resource_id=resource_id)
    for interval in working_intervals:
        work_intervals = self.interval_remove_leaves(interval, leaves)
        intervals += work_intervals
    return intervals
