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()); }
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."); }