diff --git a/beets/dbcore/query.py b/beets/dbcore/query.py index 5ef440b5e..fbe6626c7 100644 --- a/beets/dbcore/query.py +++ b/beets/dbcore/query.py @@ -562,7 +562,7 @@ class Period(object): ('%Y-%m-%dT%H:%M', '%Y-%m-%d %H:%M'), # minute ('%Y-%m-%dT%H:%M:%S', '%Y-%m-%d %H:%M:%S') # second ) - relative = {'y': 365, 'm': 30, 'w': 7, 'd': 1} + relative_units = {'y': 365, 'm': 30, 'w': 7, 'd': 1} relative_re = '(?P[+|-]?)(?P[0-9]+)' + \ '(?P[y|m|w|d])' @@ -618,10 +618,10 @@ class Period(object): # Add or subtract the given amount of time from the current # date. multiplier = -1 if sign == '-' else 1 - days = cls.relative[timespan] + days = cls.relative_units[timespan] date = datetime.now() + \ timedelta(days=int(quantity) * days) * multiplier - string = date.strftime(cls.date_formats[5][0]) + return cls(date, cls.precisions[5]) # Check for an absolute date. date, ordinal = find_date_and_format(string) @@ -637,8 +637,6 @@ class Period(object): """ precision = self.precision date = self.date - if 'relative' == self.precision: - return date if 'year' == self.precision: return date.replace(year=date.year + 1, month=1) elif 'month' == precision: diff --git a/docs/reference/query.rst b/docs/reference/query.rst index fa1286c8c..bb14f3cd2 100644 --- a/docs/reference/query.rst +++ b/docs/reference/query.rst @@ -165,8 +165,7 @@ and day are optional. If you leave out the day, for example, you will get matches for the whole month. You can also use relative dates to the current time. -A relative date begins with an ``@``. -It looks like ``@-3w``, ``@2m`` or ``@-4d`` which means the date 3 weeks ago, +It looks like ``-3w``, ``2m`` or ``-4d`` which means the date 3 weeks ago, the date 2 months from now and the date 4 days ago. A relative date consists of three parts: - ``+`` or ``-`` sign is optional and defaults to ``+``. The ``+`` sign will