From 97cce5ea595fa84789150c18e485d5f1c18cf66f Mon Sep 17 00:00:00 2001 From: Luis Miguel Almánzar Date: Sun, 26 May 2013 02:41:37 -0400 Subject: reading missing data for tv series, and populating series end date --- .../Extensions/XmlExtensions.cs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'MediaBrowser.Controller/Extensions/XmlExtensions.cs') diff --git a/MediaBrowser.Controller/Extensions/XmlExtensions.cs b/MediaBrowser.Controller/Extensions/XmlExtensions.cs index 941d9fca7..d28febe7c 100644 --- a/MediaBrowser.Controller/Extensions/XmlExtensions.cs +++ b/MediaBrowser.Controller/Extensions/XmlExtensions.cs @@ -108,6 +108,38 @@ namespace MediaBrowser.Controller.Extensions return defaultString; } + /// + /// Safes the get DateTime. + /// + /// The doc. + /// The path. + /// System.DateTime. + public static DateTime? SafeGetDateTime(this XmlDocument doc, string path) + { + return SafeGetDateTime(doc, path, null); + } + + /// + /// Safes the get DateTime. + /// + /// The doc. + /// The path. + /// The default date. + /// System.DateTime. + public static DateTime? SafeGetDateTime(this XmlDocument doc, string path, DateTime? defaultDate) + { + var rvalNode = doc.SelectSingleNode(path); + + if (rvalNode != null) + { + var text = rvalNode.InnerText; + DateTime date; + if (DateTime.TryParse(text, out date)) + return date; + } + return defaultDate; + } + /// /// Safes the get string. /// -- cgit v1.2.3