def _fuzzy_time_parse(self, value):
        """ Parses a fuzzy time value into a meaningful interpretation.

            `value`
                String value to parse.
            """

        value = value.lower().strip()
        today = datetime.date.today()

        if value in ('today', 't'):
            return today

        else:
            kwargs = {}

            if value in ('y', 'yesterday'):
                kwargs['days'] = -1

            elif value in ('w', 'wk', 'week', 'last week'):
                kwargs['days'] = -7

            else:
                # match days
                match = re.match(r'(\d+)\s*(d|day|days)\s*(ago)?$', value)
                if match:
                    kwargs['days'] = -int(match.groups(1)[0])

                else:
                    # match weeks
                    match = re.match(r'(\d+)\s*(w|wk|week|weeks)\s*(ago)?$',
                                     value)
                    if match:
                        kwargs['weeks'] = -int(match.groups(1)[0])

            if kwargs:
                return today + datetime.timedelta(**kwargs)

            return None
def _fuzzy_time_parse ( self , value ) : value = value . lower ( ) . strip ( ) today = datetime . date . today ( ) if value in ( 'today' , 't' ) : return today else : kwargs = { } if value in ( 'y' , 'yesterday' ) : kwargs [ 'days' ] = - 1 elif value in ( 'w' , 'wk' , 'week' , 'last week' ) : kwargs [ 'days' ] = - 7 else : match = re . match ( r'(\d+)\s*(d|day|days)\s*(ago)?$' , value ) if match : kwargs [ 'days' ] = - int ( match . groups ( 1 ) [ 0 ] ) else : match = re . match ( r'(\d+)\s*(w|wk|week|weeks)\s*(ago)?$' , value ) if match : kwargs [ 'weeks' ] = - int ( match . groups ( 1 ) [ 0 ] ) if kwargs : return today + datetime . timedelta ( ** kwargs ) return None
Parses a fuzzy time value into a meaningful interpretation.

            `value`
                String value to parse.