Esempio n. 1
0
        private IEnumerable <DayModel> GetDays(LocalDate localDate)
        {
            var firstDayOfWeek   = (int)_cultureInfo.DateTimeFormat.FirstDayOfWeek;
            var currentDayOfWeek = (int)localDate.DayOfWeek;
            var offsetDays       = -(currentDayOfWeek - firstDayOfWeek);

            var startWeekDate = localDate.PlusDays(offsetDays);

            for (int i = 0; i < 7; i++)
            {
                var date     = startWeekDate.PlusDays(i);
                var dayModel = new DayModel(_cultureInfo, date);
                dayModel.IsInMonth = date.Month == _date.Month;
                yield return(dayModel);
            }
        }
Esempio n. 2
0
        private IEnumerable <DayModel> GetWeekdays()
        {
            var days           = new DayModel[7];
            var dateTimeFormat = CultureInfo.DateTimeFormat;
            var firstDay       = (int)dateTimeFormat.FirstDayOfWeek.ToIsoDayOfWeek();

            for (var i = 0; i < days.Length; i++)
            {
                var current = firstDay + i;
                if (current >= 8)
                {
                    current -= 7;
                }
                var currentDay = (IsoDayOfWeek)current;
                days[i] = new DayModel(dateTimeFormat.GetAbbreviatedDayName(currentDay.ToDayOfWeek()), currentDay);
            }
            return(days);
        }