public static UnixUtcTime StartOfDay(this UnixUtcTime time) { var moment = DateTimeOffset.FromUnixTimeMilliseconds(time); var startOfDay = new DateTimeOffset(moment.Year, moment.Month, moment.Day, 0, 0, 0, TimeSpan.Zero); return(new UnixUtcTime(startOfDay.ToUnixTimeMilliseconds())); }
public static UnixUtcTime Next(this UnixUtcTime start, DayOfWeek day) { var nextDay = start.Plus(TimeSpan.FromDays(1)); var daysToAdd = ((int)day - (int)nextDay.DayOfWeek + 7) % 7; return(nextDay.Plus(TimeSpan.FromDays((daysToAdd)))); }
public static IEnumerable <UnixUtcTime> Every(this UnixUtcTime from, TimeSpan interval) { for (var time = from; time.IsBefore(long.MaxValue); time = time.Plus(interval)) { yield return(time); } }
public RecurringScheduledTask(UnixUtcTime firstExecution, TimeSpan interval, Action task) { _timer = new Timer(x => task(), new object(), -1, -1); _firstExecution = firstExecution; _interval = interval; }
public static DateTime ToDateTime(UnixUtcTime time) { return(DateTimeOffset.FromUnixTimeMilliseconds(time.Millis).UtcDateTime); }
public UnixUtcTime Minus(UnixUtcTime time) { return(new UnixUtcTime(Millis - time.Millis)); }
public static IEnumerable <UnixUtcTime> Until(this IEnumerable <UnixUtcTime> stream, UnixUtcTime until) { return(stream.TakeWhile(x => x.IsBefore(until))); }
private Epoch(UnixUtcTime time) { _time = time; }
public T At(UnixUtcTime time) { return(_sequence.Where(x => !x.Key.IsAfter(time)) .Select(x => x.Value) .LastOrDefault(_default)); }
public void Add(UnixUtcTime time, T value) { _sequence.Add(new KeyValuePair <UnixUtcTime, T>(time, value)); _sequence.Sort((l, r) => l.Key.CompareTo(r.Key)); }