tag icon indicating copy to clipboard operation
tag copied to clipboard

Feature Request: Expose Date() ISO-8601 string

Open shawnsmithdev opened this issue 5 years ago • 2 comments

The current Year() API is somewhat lacking. An artist may release multiple albums in one year, but with this API one cannot sort those albums chronologically.

I humbly suggest that we expose a new Date() string{...} method that returns ISO-8601 dates, which is to say, depending on available metadata:

  • empty string (no date metadata found)
  • 2018
  • 2018-01
  • 2018-01-15

If this sounds feasible I might try a hand at writing it myself and putting in a PR, but it seems obvious and I wonder if I'm missing a technical reason why Year() was done the way it was.

shawnsmithdev avatar Jan 15 '19 21:01 shawnsmithdev

This is an interesting idea. The varying precision provided by the different metadata types is very frustrating. At one point I considered adding a Date method

Date() time.Time

but then decided against it because too many dates would then have silly values like 2008-01-01 where only the year 2008 is given etc...

Having a string value, that then requires more post-processing by the user is frustrating too, because you then have to introspect the string to work out what it actually means... Maybe we should just add our own date type or something!

dhowden avatar Feb 04 '19 00:02 dhowden

Yes if we try parse these, we'd need to store how much precision the value has.

However, my use case is just for sorting, where I actually don't need to process the string at all if the tags actually conform to ISO-8601 (as then it will just sort lexicographical).

I have already done this in my fork and it seems to work, though the test files are only partially updated because id3 and atom are just super weird. I'll probably throw in into a PR soonish.

shawnsmithdev avatar Feb 04 '19 03:02 shawnsmithdev