/// <summary>
        /// Dates diff.
        /// </summary>
        /// <param name="Interval">The interval.</param>
        /// <param name="Date1">The date1.</param>
        /// <param name="Date2">The date2.</param>
        /// <returns>The date diff</returns>
        public static long DateDiff(string Interval, DateTime Date1, DateTime Date2)
        {
            try
            {
                TimeSpan span = Date2.Subtract(Date1);
                switch (Interval.ToLowerInvariant())
                {
                case "y":
                    return(Date2.Year - Date1.Year);

                case "mm":
                    return(((Date2.Year * 12) + Date2.Month) - ((Date1.Year * 12) + Date1.Month));

                case "d":
                    return((long)span.TotalDays);

                case "w":
                    return((long)span.TotalDays / 7);

                case "h":
                    return((long)span.TotalHours);

                case "m":
                    return((long)span.TotalMinutes);

                case "s":
                    return((long)span.TotalSeconds);
                }
            }
            catch (Exception ex)
            {
                SPSDebug.DumpException("DateDiff", ex);
            }
            return(0);
        }
 /// <summary>
 /// Maps to icon.
 /// </summary>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="programId">The program id.</param>
 /// <returns>The icon file</returns>
 public string MapToIcon(string fileName, string programId)
 {
     try
     {
         return(SPUtility.MapToIcon(SPContext.Current.Web, fileName, programId));
     }
     catch (Exception ex)
     {
         SPSDebug.DumpException("MapToIcon", ex);
     }
     return(string.Empty);
 }
 /// <summary>
 /// URLs the name of the dir.
 /// </summary>
 /// <param name="targetUrl">The target URL.</param>
 /// <returns>The Url</returns>
 public string UrlDirName(string targetUrl)
 {
     try
     {
         int index = targetUrl.IndexOf('/');
         int num2  = targetUrl.LastIndexOf('/');
         if (index < num2)
         {
             return(targetUrl.Substring(index, num2 - index));
         }
     }
     catch (Exception ex)
     {
         SPSDebug.DumpException("UrlDirName", ex);
     }
     return(string.Empty);
 }