This occurred to me when I first saw #182.
Looking at the Album attributes got me thinking. The album dict already has a release_date key alongside the release_date_components. I don't know why I chose to use release_date_components instead because release_date is just what we need for converting the release date to a datetime type. We should've used release_date for three reasons:
release_date_components has the accurate date; if the release date has no month or day, its value will just be None. But that's not the case for release_date. The release_date value will display what it has and replaces what it doesn't with 01, just how Python does in datetime objects!
- We should convert
release_date to datetime to offer a convenient way for accessing the date. And we should keep release_date_compnents as it is for users who want an accurate date.
- Converting
release_date to datetime is easy; it's either None or a string with the %Y-%m-%d format.
To sum up, this is how we should've created Album objects:
def __init__(self, client, json_dict, tracks):
body = json_dict
...
self.release_date = convert_to_datetime(body["release_date_components"])
self.release_date_components = body['release_date_components']
...
This will be a breaking change and we should hold off on changing Album.release_date_components till v4.
This occurred to me when I first saw #182.
Looking at the
Albumattributes got me thinking. The album dict already has arelease_datekey alongside therelease_date_components. I don't know why I chose to userelease_date_componentsinstead becauserelease_dateis just what we need for converting the release date to a datetime type. We should've usedrelease_datefor three reasons:release_date_componentshas the accurate date; if the release date has no month or day, its value will just be None. But that's not the case forrelease_date. Therelease_datevalue will display what it has and replaces what it doesn't with01, just how Python does in datetime objects!release_dateto datetime to offer a convenient way for accessing the date. And we should keeprelease_date_compnentsas it is for users who want an accurate date.release_dateto datetime is easy; it's eitherNoneor a string with the%Y-%m-%dformat.To sum up, this is how we should've created
Albumobjects:This will be a breaking change and we should hold off on changing
Album.release_date_componentstill v4.