private DateTime?ReadId3Date(TagLib.Id3v2.Tag tag, string dateTag) { string date = tag.GetTextAsString(dateTag); if (tag.Version == 4) { // the unabused TDRC/TDOR tags return(DateTime.TryParse(date, out DateTime result) ? result : default(DateTime?)); } else if (dateTag == "TDRC") { // taglib maps the v3 TYER and TDAT to TDRC but does it incorrectly return(DateTime.TryParseExact(date, "yyyy-dd-MM", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime result) ? result : default(DateTime?)); } else { // taglib maps the v3 TORY to TDRC so we just get a year return(int.TryParse(date, out int year) && year >= 1860 && year <= DateTime.UtcNow.Year + 1 ? new DateTime(year, 1, 1) : default(DateTime?)); } }