mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 13:07:09 +01:00
Merge branch 'relativedate'
This commit is contained in:
commit
eaae3fbd30
2 changed files with 4 additions and 7 deletions
|
|
@ -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<sign>[+|-]?)(?P<quantity>[0-9]+)' + \
|
||||
'(?P<timespan>[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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue