Esempio n. 1
0
        /// <summary>
        /// careful, can't return null, so give MinValue
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <param name="attributeName"></param>
        /// <param name="defaultDateTime">the time to use if this attribute isn't found</param>
        /// <returns></returns>
        private DateTime GetOptionalDate(XmlNode xmlNode, string attributeName, DateTime defaultDateTime)
        {
            if (xmlNode.Attributes != null)
            {
                XmlAttribute attr = xmlNode.Attributes[attributeName];
                if (attr == null)
                {
                    return(defaultDateTime);
                }

                /* if the incoming data lacks a time, we'll have a kind of 'unspecified', else utc */

                try
                {
                    return(Extensible.ParseDateTimeCorrectly(attr.Value));
                }
                catch (Exception e)
                {
                    NotifyFormatError(e); // not a fatal error
                }
            }
            return(defaultDateTime);
        }