convert log timestamp to days

def timestamp_to_days(self, timestamp):
        '''convert log timestamp to days'''
        if self.tday_base is None:
            try:
                self.tday_base = matplotlib.dates.date2num(datetime.datetime.fromtimestamp(timestamp+self.timeshift))
                self.tday_basetime = timestamp
            except ValueError:
                # this can happen if the log is corrupt
                # ValueError: year is out of range
                return 0
        sec_to_days = 1.0 / (60*60*24)
        return self.tday_base + (timestamp - self.tday_basetime) * sec_to_days