static ITag ScanDayNames(Token token, Options options) { ITag tag = null; DayPatterns.ForEach(item => { if (item.Pattern.IsMatch(token.Word)) { tag = new RepeaterDayName(item.Day); return; } }); return(tag); }
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.DayOfWeek == GetStartOfWeek()) ? now.AddDays(1).Date : 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); }