コード例 #1
0
        private void _timerCheckForNewEpisode_Elapsed(object sender, ElapsedEventArgs e)
        {
            _timerCheckForNewEpisode.Stop();
            _timerCheckForNewEpisode.Interval = TimeSpan.FromMinutes(Settings.Default.CheckForNewEpisodeInterval).TotalMilliseconds;
            //await Task.Factory.StartNew(() =>
            //{
            DateTime[] week = new DateTime[7];
            var currentDay = -1 * (int)DateTime.Now.DayOfWeek;
            for (int iter = 0; iter < week.Length; iter++)
            {
                week[iter] = DateTime.Now.AddDays(iter + currentDay).Date;
            }
            for (int i = 0; i < _subbedShows.Count; i++)
            {
                TvShow showToCheck = _subbedShows[i];
                showToCheck.Fetched = false;
                showToCheck = _repo.FetchShow(showToCheck);
                _repo.UpdateShow(showToCheck);

                TvEpisode lastEpisode =
                    (from ep in showToCheck.Seasons.Last().Episodes
                     where (!string.IsNullOrEmpty(ep.AirDate) && week.Contains(DateTime.ParseExact(ep.AirDate, Data.Settings.DATE_PARSING_MASK, null)))
                     select ep).FirstOrDefault();
                if (lastEpisode != null)
                {

                }
            }
            _timerCheckForNewEpisode.Start();
        }
コード例 #2
0
ファイル: DateTimeManagerTest.cs プロジェクト: evkap/DVS
		public DateTimeManagerTest()
		{
			_referenceManagement = Substitute.For<IReferenceManagement>();

			DateTime[] holidays = new DateTime[]
			{
				new DateTime(2012, 01, 02),
				new DateTime(2012, 01, 16),
				new DateTime(2012, 02, 20),
				new DateTime(2012, 05, 28),
				new DateTime(2012, 07, 04),
				new DateTime(2012, 09, 03),
				new DateTime(2012, 10, 08),
				new DateTime(2012, 11, 12),
				new DateTime(2012, 11, 22),
				new DateTime(2012, 12, 15),
			};
			_referenceManagement.IsHolidayDay(Arg.Is<DateTime>(e => holidays.Contains(e.Date))).Returns(true);

			_dateTimeManager = new DateTimeManager(_referenceManagement);
		}
コード例 #3
0
ファイル: CountWorkDays.cs プロジェクト: sashkooooy/MyRepo
        public static void Main()
        {
            DateTime startDate = DateTime.ParseExact(Console.ReadLine(), "dd-MM-yyyy", CultureInfo.InvariantCulture);
            DateTime endDate = DateTime.ParseExact(Console.ReadLine(), "dd-MM-yyyy", CultureInfo.InvariantCulture);
            int workingDays = 0;

            DateTime[] holidays = new DateTime[]
            {
                new DateTime(1, 1, 1),
                new DateTime(1, 3, 3),
                new DateTime(1, 5, 1),
                new DateTime(1, 5, 6),
                new DateTime(1, 5, 24),
                new DateTime(1, 9, 6),
                new DateTime(1, 9, 22),
                new DateTime(1, 11, 1),
                new DateTime(1, 12, 24),
                new DateTime(1, 12, 25),
                new DateTime(1, 12, 26),
            };

            for (DateTime date = startDate; date <= endDate;date = date.AddDays(1))
            {
                DateTime tempDate = new DateTime(1, date.Month, date.Day);

                bool isWeekDay = date.DayOfWeek != DayOfWeek.Saturday && date.DayOfWeek != DayOfWeek.Sunday;
                bool isHoliday = holidays.Contains(tempDate);

                if (isWeekDay && !isHoliday)
                {
                    workingDays ++;
                }
            }

            Console.WriteLine(workingDays);
        }