(self)
return output
Generate a 'filterable' range from the current date and filter delta.
        Ex.
            With:
                self.filter_type = 'relative_range'
                self.filter_delta = -60 * 60 * 24 * 2 (i.e. -2 days)
            Return:
                # a 'negative' two day range from filter_value
                ["2017-01-01", "2017-01-03"]
Generate a 'filterable' range from the current date and filter delta.
        Ex.
            With:
                self.filter_type = 'relative_range'
                self.filter_delta = -60 * 60 * 24 * 2 (i.e. -2 days)
            Return:
                # a 'negative' two day range from filter_value
                ["2017-01-01", "2017-01-03"]
Generate a filterable range from the current date and filter delta . Ex . With : self . filter_type = relative_range self . filter_delta = - 60 * 60 * 24 * 2 ( i . e . - 2 days ) Return : # a negative two day range from filter_value [ 2017 - 01 - 01 2017 - 01 - 03 ]
def get_relative_range(self):
        """
        Generate a 'filterable' range from the current date and filter delta.
        Ex.
            With:
                self.filter_type = 'relative_range'
                self.filter_delta = -60 * 60 * 24 * 2 (i.e. -2 days)
            Return:
                # a 'negative' two day range from filter_value
                ["2017-01-01", "2017-01-03"]
        """
        day = 60 * 60 * 24

        if self.field_type == 'DateField':
            if abs(self.filter_delta) < day:
                raise ValidationError(
                    'DateField delta must be at least 1 day.')
            first = datetime.date.today()
            second = first + datetime.timedelta(seconds=self.filter_delta)
            output_range = sorted([first, second])
            output = [date.strftime("%Y-%m-%d") for date in output_range]

        elif self.field_type == 'DateTimeField':
            first = datetime.datetime.now()
            second = first + datetime.timedelta(seconds=self.filter_delta)
            output_range = sorted([first, second])
            output = [date.strftime("%Y-%m-%d %H:%M:%S") for date in output_range]

        elif self.field_type == 'TimeField':
            day_const = datetime.datetime(1, 1, 1)
            first = datetime.datetime.now().time()
            delta = datetime.timedelta(seconds=self.filter_delta)
            diff = datetime.datetime.combine(day_const, first) + delta
            second = diff.time()
            output_range = sorted([first, second])
            output = [date.strftime("%H:%M") for date in output_range]

        return output
def get_relative_range ( self ) : day = 60 * 60 * 24 if self . field_type == 'DateField' : if abs ( self . filter_delta ) < day : raise ValidationError ( 'DateField delta must be at least 1 day.' ) first = datetime . date . today ( ) second = first + datetime . timedelta ( seconds = self . filter_delta ) output_range = sorted ( [ first , second ] ) output = [ date . strftime ( "%Y-%m-%d" ) for date in output_range ] elif self . field_type == 'DateTimeField' : first = datetime . datetime . now ( ) second = first + datetime . timedelta ( seconds = self . filter_delta ) output_range = sorted ( [ first , second ] ) output = [ date . strftime ( "%Y-%m-%d %H:%M:%S" ) for date in output_range ] elif self . field_type == 'TimeField' : day_const = datetime . datetime ( 1 , 1 , 1 ) first = datetime . datetime . now ( ) . time ( ) delta = datetime . timedelta ( seconds = self . filter_delta ) diff = datetime . datetime . combine ( day_const , first ) + delta second = diff . time ( ) output_range = sorted ( [ first , second ] ) output = [ date . strftime ( "%H:%M" ) for date in output_range ] return output