(interval)
return start_range.strftime(TS_FORMAT), end_range.strftime(TS_FORMAT)
Convert an interval timestamp into start and end dates.

        Args:
            interval: Time frame representation

        Returns:
            Start timestamp in string format.
            End timestamp in string format.
Convert an interval timestamp into start and end dates.
Convert an interval timestamp into start and end dates .
def _convert_to_time_range(interval):
        """Convert an interval timestamp into start and end dates.

        Args:
            interval: Time frame representation

        Returns:
            Start timestamp in string format.
            End timestamp in string format.
        """
        # return ('2018-12-05T00:00:00', '2018-12-05T23:59:59')
        TS_FORMAT = '%Y-%m-%dT%H:%M:%S'
        get_digits = lambda s: int(''.join(filter(str.isdigit, s)))
        get_alpha = lambda s: ''.join(filter(str.isalpha, s))

        ts_parts = interval.split(' ')
        # The start date could be 1 or 2 first items
        start = ' '.join(ts_parts[0:len(ts_parts)-2])
        minus = get_digits(ts_parts[-2])
        plus = get_digits(ts_parts[-1])
        interval = get_alpha(ts_parts[-1])

        start_ts = parser.parse(start)

        rd = relativedelta.relativedelta
        if interval == 's':
            start_range = start_ts - rd(seconds=minus)
            end_range = start_ts + rd(seconds=plus)
        elif interval == 'm':
            start_range = start_ts - rd(minutes=minus)
            end_range = start_ts + rd(minutes=plus)
        elif interval == 'h':
            start_range = start_ts - rd(hours=minus)
            end_range = start_ts + rd(hours=plus)
        elif interval == 'd':
            start_range = start_ts - rd(days=minus)
            end_range = start_ts + rd(days=plus)
        else:
            raise RuntimeError('Unable to parse the timestamp: '
                               + str(interval))

        return start_range.strftime(TS_FORMAT), end_range.strftime(TS_FORMAT)
def _convert_to_time_range ( interval ) : # return ('2018-12-05T00:00:00', '2018-12-05T23:59:59') TS_FORMAT = '%Y-%m-%dT%H:%M:%S' get_digits = lambda s : int ( '' . join ( filter ( str . isdigit , s ) ) ) get_alpha = lambda s : '' . join ( filter ( str . isalpha , s ) ) ts_parts = interval . split ( ' ' ) # The start date could be 1 or 2 first items start = ' ' . join ( ts_parts [ 0 : len ( ts_parts ) - 2 ] ) minus = get_digits ( ts_parts [ - 2 ] ) plus = get_digits ( ts_parts [ - 1 ] ) interval = get_alpha ( ts_parts [ - 1 ] ) start_ts = parser . parse ( start ) rd = relativedelta . relativedelta if interval == 's' : start_range = start_ts - rd ( seconds = minus ) end_range = start_ts + rd ( seconds = plus ) elif interval == 'm' : start_range = start_ts - rd ( minutes = minus ) end_range = start_ts + rd ( minutes = plus ) elif interval == 'h' : start_range = start_ts - rd ( hours = minus ) end_range = start_ts + rd ( hours = plus ) elif interval == 'd' : start_range = start_ts - rd ( days = minus ) end_range = start_ts + rd ( days = plus ) else : raise RuntimeError ( 'Unable to parse the timestamp: ' + str ( interval ) ) return start_range . strftime ( TS_FORMAT ) , end_range . strftime ( TS_FORMAT )