예제 #1
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(GetStartOfWeek());
                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(GetStartOfWeek());
                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(GetStartOfWeek());
                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);
        }