forked from 0x2620/pandora
try date formats
This commit is contained in:
parent
1d6d53e282
commit
f591f66634
1 changed files with 10 additions and 3 deletions
|
@ -1032,9 +1032,16 @@ class Item(models.Model):
|
|||
elif sort_type == 'date':
|
||||
value = self.get(source)
|
||||
if isinstance(value, string_types):
|
||||
value = datetime_safe.datetime.strptime(value, '%Y-%m-%d')
|
||||
set_value(s, name, value)
|
||||
|
||||
value_ = None
|
||||
for fmt in ('%Y-%m-%d', '%Y-%m', '%Y'):
|
||||
try:
|
||||
value_ = datetime_safe.datetime.strptime(value, fmt)
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
continue
|
||||
if value_ is not None:
|
||||
set_value(s, name, value_)
|
||||
s.save()
|
||||
|
||||
def update_facet(self, key):
|
||||
|
|
Loading…
Reference in a new issue