using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace EgwCoreLib.Lux.Core { public class DtUtils { /// /// Formattaione dataora: /// - fino ad 1 h Ym Zs /// - fino ad 24h Xh Ym /// - oltre 24h Wd Xh Ym /// /// Timespan da mostrare /// public static string FormatDateTime(TimeSpan tsReq) { if (tsReq.TotalHours < 1) { // Only minutes and seconds return $"{tsReq.Minutes:00}\' {tsReq.Seconds:00}\""; } else if (tsReq.TotalHours < 24) { // Hours, minutes, seconds return $"{tsReq.Hours}h {tsReq.Minutes:00}\'"; } else { // Days + hours + minutes return $"{tsReq.Days}d {tsReq.Hours}h {tsReq.Minutes:00}\'"; } } } }