Пример #1
0
        private void GetWeekFirstLastDay()
        {
            var firstOfThisYear     = new DateTime(year, 1, 1);
            var dayOfWeekOfThisYear = culture.Calendar.GetDayOfWeek(firstOfThisYear);
            var isThur       = dayOfWeekOfThisYear == DayOfWeek.Thursday;
            var isLeapAndWed = DateTime.DaysInMonth(year, 2) == 29 && dayOfWeekOfThisYear == DayOfWeek.Wednesday;

            if (isThur || isLeapAndWed)
            {
                weeksOfYear = 53;
            }
            else
            {
                weeksOfYear = 52;
            }

            if (isLastYearLeapAndWed())
            {
                firstDay = firstOfThisYear.AddDays(week * 7 - (int)dayOfWeekOfThisYear + 1);
            }
            else
            {
                firstDay = firstOfThisYear.AddDays((week - 1) * 7 - (int)dayOfWeekOfThisYear + 1);
            }

            CheckWeekOutRange();
            lastDay = FirstDay.AddDays(7);
        }
Пример #2
0
        public ScheduleDay GetScheduleDay(int dayNumber)
        {
            var day = FirstDay.AddDays(dayNumber - 1);

            if (day.Month != FirstDay.Month)
            {
                return(null);
            }
            return(new ScheduleDay(day, IsHoliday(day), IsPreHoliday(day), IsRestday(day), IsMove(day), GetTooltip(day)));
        }
Пример #3
0
        public CalendarWeekViewModel(DateTime date)
        {
            _date = date;

            // Vytvoření Commandů pro navigaci kalendářem po týdnech
            Command_CurrentWeek  = new ChangeViewModelCommand <CalendarWeekViewModel>(DateTime.Now);
            Command_PreviousWeek = new ChangeViewModelCommand <CalendarWeekViewModel>(_date.AddDays(-7));
            Command_NextWeek     = new ChangeViewModelCommand <CalendarWeekViewModel>(_date.AddDays(7));

            DayCells = new();
            for (int i = 0; i < 7; i++)
            {
                DayCells.Add(new DayCellViewModel(FirstDay.AddDays(i)));
            }
        }
Пример #4
0
        public WeekOvertime(int year, int week, double worktime, double requiredtime)
        {
            var dfi            = DateTimeFormatInfo.CurrentInfo;
            var cal            = dfi.Calendar;
            var fd             = dfi.FirstDayOfWeek;
            var firstinyear    = new DateTime(year, 1, 1);
            var firstDayOfWeek = firstinyear.AddDays(dfi.FirstDayOfWeek - firstinyear.DayOfWeek);

            Year                    = year;
            Week                    = week;
            FirstDay                = firstDayOfWeek.AddDays(7 * (week - 1));
            LastDay                 = FirstDay.AddDays(6.0);
            WorkTimePerWeek         = worktime;
            RequiredWorkTimePerWeek = requiredtime;
        }
 public Calendar(
     DateTime startDate,
     int length,
     ICollection <DateTime> holidays,
     ICollection <DayOfWeek> weekDays)
 {
     if (length < 1)
     {
         throw new ArgumentOutOfRangeException(nameof(length), "The minimum length is one day.");
     }
     for (var x = 0; x < length; x++)
     {
         var addingDate = new CalendarDate
         {
             RepresentedDate = startDate.Date.AddDays(x),
         };
         addingDate.IsHoliday = holidays.Contains(addingDate.RepresentedDate);
         addingDate.IsWeekday = weekDays.Contains(addingDate.RepresentedDate.DayOfWeek);
         _dates.Add(addingDate);
     }
     FirstDay = startDate.Date;
     LastDay  = FirstDay.AddDays(length - 1);
 }