def __parse_offset()

in eventdata/parameter_sources/timeutils.py [0:0]


    def __parse_offset(self, offset):
        if offset is None:
            return datetime.timedelta()
        match = re.match(r"^([+-]\d+)([hmd])$", offset)
        if match:
            offset_amount = int(match.group(1))
            if match.group(2) == "m":
                return datetime.timedelta(minutes=offset_amount)
            elif match.group(2) == "h":
                return datetime.timedelta(hours=offset_amount)
            elif match.group(2) == "d":
                return datetime.timedelta(days=offset_amount)
            else:
                raise TimeParsingError("Invalid offset: {}".format(offset))
        else:
            raise TimeParsingError("Invalid offset: {}".format(offset))