Ejemplo n.º 1
0
        public static string AddTimeSpan(this TimeSpanIntervals interval, double quantity, DateTime?date = null)
        {
            if (!date.HasValue)
            {
                date = DateTime.UtcNow;
            }

            return(date.Value.Add(interval.ToTimeSpan(quantity)).ToJSONString());
        }
Ejemplo n.º 2
0
        public static TimeSpan ToTimeSpan(this TimeSpanIntervals interval, double quantity)
        {
            switch (interval)
            {
            case TimeSpanIntervals.Minutes: return(TimeSpan.FromMinutes(quantity));

            case TimeSpanIntervals.Hours: return(TimeSpan.FromHours(quantity));

            case TimeSpanIntervals.Days: return(TimeSpan.FromDays(quantity));
            }

            throw new NotSupportedException($"Unknown case {interval} - note creating a time span from NotApplicable is not supported.");
        }