Skip to content

Album.GetReleaseDate() exception #7

@GoogleCodeExporter

Description

@GoogleCodeExporter
Release date can be empty in xml string. DateTime.parse throws an 
exception.

Possible fix (check for empty value, return Nullable DateTime)

        /// <summary>
        /// Returns the album's release date.
        /// </summary>
        /// <returns>
        /// A <see cref="DateTime"/>
        /// </returns>
        public DateTime? GetReleaseDate()
        {
            XmlDocument doc = request("album.getInfo");
          string releaseDate = extract(doc, "releasedate");
      if (!string.IsNullOrEmpty(releaseDate))
            return DateTime.Parse(releaseDate);

          return null;
        }

Maybe even do a DateTime.TryParse


Original issue reported on code.google.com by mkrijten...@gmail.com on 28 Apr 2010 at 8:17

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions