示例#1
0
 public override Span GetOffset(Span span, int amount, Pointer.Type pointer)
 {
     var direction = (int)pointer;
     var newBegin = BuildOffsetTime(span.Start.Value, amount, direction);
     var newEnd = BuildOffsetTime(span.End.Value, amount, direction);
     return new Span(newBegin, newEnd);
 }
示例#2
0
 protected override Span CurrentSpan(Pointer.Type pointer)
 {
     Span thisSpan;
     if (pointer == Pointer.Type.Future || pointer == Pointer.Type.None)
     {
         var saturdayRepeater = new RepeaterDayName(DayOfWeek.Saturday);
         saturdayRepeater.Now = Now;
         var thisSaturdaySpan = saturdayRepeater.GetNextSpan(Pointer.Type.Future);
         thisSpan = new Span(
             thisSaturdaySpan.Start.Value,
             thisSaturdaySpan.Start.Value.AddSeconds(WEEKEND_SECONDS));
     }
     else if (pointer == Pointer.Type.Past)
     {
         var saturdayRepeater = new RepeaterDayName(DayOfWeek.Saturday);
         saturdayRepeater.Now = Now;
         var lastSaturdaySpan = saturdayRepeater.GetNextSpan(Pointer.Type.Past);
         thisSpan = new Span(
             lastSaturdaySpan.Start.Value,
             lastSaturdaySpan.Start.Value.AddSeconds(RepeaterWeekend.WEEKEND_SECONDS));
     }
     else
     {
         throw new ArgumentException("Unable to handle pointer " + pointer + ".", "pointer");
     }
     return thisSpan;
 }
示例#3
0
 public override Span GetOffset(Span span, int amount, Pointer.Type pointer)
 {
     int direction = (pointer == Pointer.Type.Future) ? 1 : -1;
     return new Span(
         span.Start.Value.AddMonths(amount * direction),
         span.End.Value.AddMonths(amount * direction)
     );
 }
示例#4
0
        public override Span GetOffset(Span span, int amount, Pointer.Type pointer)
        {
            var direction = (pointer == Pointer.Type.Future) ? 1 : -1;
            var weekend = new RepeaterWeekend();
            weekend.Now = span.Start;
            var start = weekend
                .GetNextSpan(pointer)
                .Start.Value
                .AddSeconds((amount - 1) * direction * RepeaterWeek.WEEK_SECONDS);

            return new Span(start, start.AddSeconds(span.Width));
        }
示例#5
0
        protected override Span CurrentSpan(Pointer.Type pointer)
        {
            Span thisWeekSpan;
            DateTime thisWeekStart;
            DateTime thisWeekEnd;
            var now = Now.Value;

            if (pointer == Pointer.Type.Future)
            {
                thisWeekStart = Time.New(now, now.Hour).AddHours(1);
                var sundayRepeater = new RepeaterDayName(DayOfWeek.Sunday);
                sundayRepeater.Now = now;
                var thisSundaySpan = sundayRepeater.GetCurrentSpan(Pointer.Type.Future);
                thisWeekEnd = thisSundaySpan.Start.Value;
                thisWeekSpan = new Span(thisWeekStart, thisWeekEnd);
            }
            else if (pointer == Pointer.Type.Past)
            {
                thisWeekEnd = now;
                var sundayRepeater = new RepeaterDayName(DayOfWeek.Sunday);
                sundayRepeater.Now = now;
                var lastSundaySpan = sundayRepeater.GetNextSpan(Pointer.Type.Past);
                thisWeekStart = lastSundaySpan.Start.Value;
                thisWeekSpan = new Span(thisWeekStart, thisWeekEnd);
            }
            else if (pointer == Pointer.Type.None)
            {
                var sundayRepeater = new RepeaterDayName(DayOfWeek.Sunday);
                sundayRepeater.Now = now;
                Span lastSundaySpan = sundayRepeater.GetNextSpan(Pointer.Type.Past);
                thisWeekStart = lastSundaySpan.Start.Value;
                thisWeekEnd = thisWeekStart.AddDays(RepeaterWeek.WEEK_DAYS);
                thisWeekSpan = new Span(thisWeekStart, thisWeekEnd);
            }
            else
            {
                throw new ArgumentException("Unable to handle pointer " + pointer + ".", "pointer");
            }
            return thisWeekSpan;
        }
示例#6
0
 public override Span GetOffset(Span span, int amount, Pointer.Type pointer)
 {
     int direction = (pointer == Pointer.Type.Future) ? 1 : -1;
     return span.Add(direction * amount * RepeaterMinute.MINUTE_SECONDS);
 }
示例#7
0
 public override Span GetOffset(Span span, int amount, Pointer.Type pointer)
 {
     throw new NotImplementedException();
 }
示例#8
0
 public override Span GetOffset(Span span, int amount, Pointer.Type pointer)
 {
     var direction = (pointer == Pointer.Type.Future) ? 1 : -1;
     return span.Add(direction * amount * RepeaterWeek.WEEK_SECONDS);
 }