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 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()));
        }
Esempio n. 4
0
 public static DateTime ToDateTime(UnixUtcTime time)
 {
     return(DateTimeOffset.FromUnixTimeMilliseconds(time.Millis).UtcDateTime);
 }
Esempio n. 5
0
 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)));
 }
Esempio n. 7
0
 private Epoch(UnixUtcTime time)
 {
     _time = time;
 }
Esempio n. 8
0
 public T At(UnixUtcTime time)
 {
     return(_sequence.Where(x => !x.Key.IsAfter(time))
            .Select(x => x.Value)
            .LastOrDefault(_default));
 }
Esempio n. 9
0
 public void Add(UnixUtcTime time, T value)
 {
     _sequence.Add(new KeyValuePair <UnixUtcTime, T>(time, value));
     _sequence.Sort((l, r) => l.Key.CompareTo(r.Key));
 }
 public RecurringScheduledTask(UnixUtcTime firstExecution, TimeSpan interval, Action task)
 {
     _timer          = new Timer(x => task(), new object(), -1, -1);
     _firstExecution = firstExecution;
     _interval       = interval;
 }