Date objects should be valid input into date fields

Issue #64 wontfix
Mike Lissner
created an issue

There are a bunch of fields that expect dates, and eyed3's API requires dates like:

audio_file.tag.recording_date = d.strftime('%Y-%m-%d')

A better API would be to accept dates like this:

audio_file.tag.recording_date = d

Feels like an easy fix that'd benefit everybody.

Comments (2)

  1. Travis Shirk repo owner

    Python dates can't be used since they don't allow for one values. You can't represent '2014' or '2014-09', for example. Both are valid dates in ID3.

    >>> from datetime import date
    >>> d = date(2014)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: Required argument 'month' (pos 2) not found
    >>> d = date(2014, 9)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: Required argument 'day' (pos 3) not found
    >>>
    

    Use of eyed3.core.Date is allowed though. Date(year, month=None, day=None, hour=None, minute=None, second=None)

    In [3]: from eyed3.core import Date
    In [4]: tag.release_date = Date(2014)
    In [5]: print tag.release_date
    2014
    
  2. Log in to comment