mediafile: Zero-padded date format

Tag files with '2000-08-01' instead of '2000-8-1'
This commit is contained in:
Thomas Scholtes 2014-09-11 11:48:34 +02:00
parent 832f34c46c
commit 7958469b25

View file

@ -1122,13 +1122,15 @@ class DateField(MediaField):
"""
if year is None:
self.__delete__(mediafile)
date = [year]
return
date = [u'{0:04d}'.format(int(year))]
if month:
date.append(month)
date.append(u'{0:02d}'.format(int(month)))
if month and day:
date.append(day)
date.append(u'{0:02d}'.format(int(day)))
date = map(unicode, date)
super(DateField, self).__set__(mediafile, '-'.join(date))
super(DateField, self).__set__(mediafile, u'-'.join(date))
if hasattr(self, '_year_field'):
self._year_field.__set__(mediafile, year)