# Buggy code
def _get_schedule(self, include_opts=True, include_pillar=True):
    """
    Return the schedule data structure
    """
    schedule = {}
    if include_pillar:
        pillar_schedule = self.opts.get("pillar", {}).get("schedule", {})
        if not isinstance(pillar_schedule, dict):
            raise ValueError("Schedule must be of type dict.")
        schedule.update(pillar_schedule)
    if include_opts:
        opts_schedule = self.opts.get("schedule", {})
        if not isinstance(opts_schedule, dict):
            raise ValueError("Schedule must be of type dict.")
        schedule.update(opts_schedule)

    return schedule


# Traceback (SaltClientError)
2018-02-26 18:02:15,266 [salt.minion      :204 ][WARNING ][16492] Master ip address changed from 10.1.51.25 to 10.1.51.24
2018-02-26 18:02:15,616 [salt.minion      :433 ][ERROR   ][16492] Exception unsupported operand type(s) for -: 'str' and 'datetime.datetime' occurred in scheduled job
2018-02-26 18:02:16,613 [salt.minion      :433 ][ERROR   ][16492] Exception unsupported operand type(s) for -: 'str' and 'datetime.datetime' occurred in scheduled job
2018-02-26 18:02:17,611 [salt.minion      :433 ][ERROR   ][16492] Exception unsupported operand type(s) for -: 'str' and 'datetime.datetime' occurred in scheduled job
2018-02-26 18:02:18,611 [salt.minion      :433 ][ERROR   ][16492] Exception unsupported operand type(s) for -: 'str' and 'datetime.datetime' occurred in scheduled job
2018-02-26 18:02:19,611 [salt.minion      :433 ][ERROR   ][16492] Exception unsupported operand type(s) for -: 'str' and 'datetime.datetime' occurred in scheduled job
2018-02-26 18:02:20,288 [salt.minion      :204 ][WARNING ][16492] Master ip address changed from 10.1.51.24 to 10.1.51.25
2018-02-26 18:02:20,611 [salt.minion      :433 ][ERROR   ][16492] Exception unsupported operand type(s) for -: 'str' and 'datetime.datetime' occurred in scheduled job
2018-02-26 18:02:21,611 [salt.minion      :433 ][ERROR   ][16492] Exception unsupported operand type(s) for -: 'str' and 'datetime.datetime' occurred in scheduled job
2018-02-26 18:02:22,610 [salt.minion      :433 ][ERROR   ][16492] Exception unsupported operand type(s) for -: 'str' and 'datetime.datetime' occurred in scheduled job
2018-02-26 18:02:23,619 [salt.minion      :433 ][ERROR   ][16492] Exception unsupported operand type(s) for -: 'str' and 'datetime.datetime' occurred in scheduled job
2018-02-26 18:02:24,620 [salt.minion      :433 ][ERROR   ][16492] Exception unsupported operand type(s) for -: 'str' and 'datetime.datetime' occurred in scheduled job
2018-02-26 18:02:25,300 [salt.minion      :644 ][ERROR   ][16492] No master could be reached or all masters denied the minion's connection attempt.
2018-02-26 18:02:25,301 [salt.scripts     :146 ][WARNING ][16492] Fatal functionality error caught by minion handler:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 144, in minion_process
minion.start()
File "/usr/lib/python2.7/site-packages/salt/cli/daemons.py", line 350, in start
raise SaltClientError('Minion could not connect to Master')
SaltClientError: Minion could not connect to Master
2018-02-26 18:02:25,301 [salt.scripts     :147 ][WARNING ][16492] ** Restarting minion **

# Fixed code
def _get_schedule(self, include_opts=True, include_pillar=True, remove_hidden=False):
    """
    Return the schedule data structure
    """
    schedule = {}
    if include_pillar:
        pillar_schedule = self.opts.get("pillar", {}).get("schedule", {})
        if not isinstance(pillar_schedule, dict):
            raise ValueError("Schedule must be of type dict.")
        schedule.update(pillar_schedule)
    if include_opts:
        opts_schedule = self.opts.get("schedule", {})
        if not isinstance(opts_schedule, dict):
            raise ValueError("Schedule must be of type dict.")
        schedule.update(opts_schedule)

    if remove_hidden:
        _schedule = copy.deepcopy(schedule)
        for job in _schedule:
            for item in _schedule[job]:
                if item.startswith("_"):
                    del schedule[job][item]
    return schedule