Mega Code Archive

 
Categories / C# / Date Time
 

Compares 2 dates ignoring the milliseconds

using System; using System.Collections.Generic; using System.Text; namespace ivware.Mobile.RAPISync.Core {   public class Utilities   {     /// <summary>     /// Compares 2 dates ignoring the milliseconds     /// <param name="i_lhs">The i_lhs.</param>     /// <param name="i_rhs">The i_rhs.</param>     /// <returns></returns>     public static bool AreEqual(DateTime i_lhs, DateTime i_rhs)     {       TimeSpan diff = i_lhs - i_rhs;       if (Math.Abs(Math.Floor(diff.TotalSeconds)) > 0)         return false;       else         return true;     }          public static string CleanFileName(string i_file)     {       string retVal = i_file.Replace("/", "");       retVal = retVal.Replace(@"\", "");       retVal = retVal.Replace(":", "");       retVal = retVal.Replace("*", "");       retVal = retVal.Replace("?", "");       retVal = retVal.Replace("\"", "");       retVal = retVal.Replace("<", "");       retVal = retVal.Replace(">", "");       retVal = retVal.Replace("|", "");       return retVal;     }   } }