crime
This commit is contained in:
parent
fda000646d
commit
28be65df85
@ -546,7 +546,7 @@ class Database:
|
|||||||
label=album_result['label'],
|
label=album_result['label'],
|
||||||
album_status=album_result['album_status'],
|
album_status=album_result['album_status'],
|
||||||
language=pycountry.languages.get(alpha_3=album_result['language']),
|
language=pycountry.languages.get(alpha_3=album_result['language']),
|
||||||
date=datetime.datetime.strptime(album_result['date'], "%Y-%m-%d").date(),
|
date=ID3Timestamp.strptime(album_result['date'], "%Y-%m-%d"),
|
||||||
country=album_result['country'],
|
country=album_result['country'],
|
||||||
barcode=album_result['barcode'],
|
barcode=album_result['barcode'],
|
||||||
is_split=album_result['is_split'],
|
is_split=album_result['is_split'],
|
||||||
|
@ -184,15 +184,42 @@ class ID3Timestamp:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def strptime(cls, time_stamp: str, format: str):
|
def strptime(cls, time_stamp: str, format: str):
|
||||||
date_obj = datetime.datetime.strftime(time_stamp, format)
|
"""
|
||||||
|
day: "%d"
|
||||||
|
month: "%b", "%B", "%m"
|
||||||
|
year: "%y", "%Y"
|
||||||
|
hour: "%H", "%I"
|
||||||
|
minute: "%M"
|
||||||
|
second: "%S"
|
||||||
|
"""
|
||||||
|
date_obj = datetime.datetime.strptime(time_stamp, format)
|
||||||
|
|
||||||
|
day = None
|
||||||
|
if "%d" in format:
|
||||||
|
day = date_obj.day
|
||||||
|
month = None
|
||||||
|
if any([i in format for i in ("%b", "%B", "%m")]):
|
||||||
|
month = date_obj.month
|
||||||
|
year = None
|
||||||
|
if any([i in format for i in ("%y", "%Y")]):
|
||||||
|
year = date_obj.year
|
||||||
|
hour = None
|
||||||
|
if any([i in format for i in ("%H", "%I")]):
|
||||||
|
hour = date_obj.hour
|
||||||
|
minute = None
|
||||||
|
if "%M" in format:
|
||||||
|
minute = date_obj.minute
|
||||||
|
second = None
|
||||||
|
if "%S" in format:
|
||||||
|
second = date_obj.second
|
||||||
|
|
||||||
return cls(
|
return cls(
|
||||||
year=date_obj.year,
|
year=year,
|
||||||
month=date_obj.month,
|
month=month,
|
||||||
day=date_obj.day,
|
day=day,
|
||||||
hour=date_obj.hour,
|
hour=hour,
|
||||||
minute=date_obj.minute,
|
minute=minute,
|
||||||
second=date_obj.second
|
second=second
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user