using System; using System.Collections.Generic; using System.Linq; using System.Web; using SteamWare; namespace MoonProTablet { public class utility { /// /// determina se si debba usare CDN x scaricare librerie asp.net ajax /// public static bool EnableCdnAjax { get { bool answ = false; try { answ = memLayer.ML.confReadBool("EnableCdnAjax"); } catch { } return answ; } } /// /// determina se si debba usare CDN x scaricare librerie jquery /// public static bool EnableCdnJQ { get { bool answ = false; try { answ = memLayer.ML.confReadBool("EnableCdnJQ"); } catch { } return answ; } } /// /// formatta la durata in minuti in un modo "human readable" gg/min/ore /// /// minuti /// public static string formatDurata(object min) { string answ = ""; DateTime tempo = new DateTime(); double minuti = 0; decimal ore = 0; decimal gg = 0; try { minuti = Convert.ToDouble(min); tempo = tempo.AddMinutes(minuti); } catch { } #if false if (minuti < memLayer.ML.confReadInt("maxMinuti")) { answ = string.Format("{0:0.##} min", minuti); } else if (minuti < memLayer.ML.confReadInt("maxOre")) { ore = Math.Floor(minuti / 60); answ = string.Format("{0} h {1:0} min", ore, minuti - 60 * ore); } else { gg = Math.Floor(minuti / (24 * 60)); ore = (minuti - (24 * 60 * gg)) / 60; answ = string.Format("{0} gg {1:0.##} h", gg, ore); } #endif if (minuti < memLayer.ML.confReadInt("maxMinuti")) { answ = string.Format("{0}m {1}s", tempo.Minute, tempo.Second); } else if (minuti < memLayer.ML.confReadInt("maxOre")) { answ = string.Format("{0}h {1}m",tempo.Hour, tempo.Minute); } else { answ = string.Format("{0}gg {1}h {2}m", tempo.DayOfYear, tempo.Hour, tempo.Minute); } return answ; } } }