예제 #1
0
        //public string _RootTag { get { return Regex.Replace(_doc.InnerXml, "^<([^< >]+) .+$", "$1"); } }

        // ----------------------------------------------------------------------------------------
        /// <!-- NullableDateTimeValue -->
        /// <summary>
        ///
        /// </summary>
        /// <param name="xPath"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public DateTime?NullableDateTimeValue(string xPath, DateTime?defaultValue)
        {
            string   str  = StrValue(xPath, "");
            DateTime?time = TreatAs.DateValue(str, defaultValue);

            return(time);
        }
예제 #2
0
        // ----------------------------------------------------------------------------------------
        /// <!-- OldestFileDateByName -->
        /// <summary>
        ///      Identifies the most recent date based on the names of the files in the list
        /// </summary>
        /// <param name="fileList">file names have YYYYMMDDHHMMDD in them somewhere</param>
        /// <returns></returns>
        public static DateTime OldestFileDateByName(FileInfo[] fileList)
        {
            DateTime oldest = DateTime.UtcNow;

            foreach (FileInfo fi in fileList)
            {
                string fileName = fi.Name;
                string strDate  = Regex.Replace(fileName, "[^0-9]", "");
                strDate = Regex.Replace(strDate, "^(....)(..)(..)(..)(..)(.*)$", "$1/$2/$3 $4:$5:$6");
                DateTime?fileNameTime = TreatAs.DateValue(strDate, null);
                if (fileNameTime != null)
                {
                    if (fileNameTime < oldest)
                    {
                        oldest = (DateTime)fileNameTime;
                    }
                }
            }

            return(oldest);
        }
예제 #3
0
        // ------------------------------------------------------------------------------
        //  Constructor
        // ------------------------------------------------------------------------------

        // ----------------------------------------------------------------------------------------
        /// <!-- NewestFileDateByName -->
        /// <summary>
        ///      Identifies the most recent date based on the names of the files in the list
        /// </summary>
        /// <param name="fileList">file names have YYYYMMDDHHMMDD in them somewhere</param>
        /// <returns></returns>
        public static DateTime NewestFileDateByName(FileInfo[] fileList)
        {
            DateTime newest = TimeDate_old.MinSqlValue.CLRFormat;

            foreach (FileInfo fi in fileList)
            {
                string fileName = fi.Name;
                string strDate  = Regex.Replace(fileName, "[^0-9]", "");
                strDate = Regex.Replace(strDate, "^(....)(..)(..)(..)(..)(.*)$", "$1/$2/$3 $4:$5:$6");
                DateTime?fileNameTime = TreatAs.DateValue(strDate, null);
                if (fileNameTime != null)
                {
                    if (fileNameTime > newest)
                    {
                        newest = (DateTime)fileNameTime;
                    }
                }
            }

            return(newest);
        }