當前位置: 首頁>>代碼示例>>C#>>正文


C# DateTime.EndOfWeek方法代碼示例

本文整理匯總了C#中System.DateTime.EndOfWeek方法的典型用法代碼示例。如果您正苦於以下問題:C# DateTime.EndOfWeek方法的具體用法?C# DateTime.EndOfWeek怎麽用?C# DateTime.EndOfWeek使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.DateTime的用法示例。


在下文中一共展示了DateTime.EndOfWeek方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: EndOfWeek

            public void EndOfWeek()
            {
                var anyDate = new DateTime(2014, 1, 3, 3, 24, 50);
                var expectedResult = DateTime.Parse("2014-01-04 23:59:59.9999999");

                Assert.Equal(expectedResult, anyDate.EndOfWeek());
            }
開發者ID:BilliamBrown,項目名稱:Chronos,代碼行數:7,代碼來源:DateTimeTests.cs

示例2: EndOfWeekTestCase1

 public void EndOfWeekTestCase1()
 {
     var dateTime = new DateTime( 2014, 3, 27 );
     var expected = new DateTime( 2014, 3, 31 ).AddDays( 1 )
                                               .Subtract( 1.ToMilliseconds() );
     var actual = dateTime.EndOfWeek( DayOfWeek.Monday );
     Assert.AreEqual( expected, actual );
 }
開發者ID:MannusEtten,項目名稱:Extend,代碼行數:8,代碼來源:DateTime.EndOfWeek.Test.cs

示例3: EndOfWeek

        public void EndOfWeek()
        {
            // Type
            var @this = new DateTime(2014, 04, 16);

            // Examples
            DateTime value = @this.EndOfWeek(); // value = "2013/04/13 23:59:59:999";

            // Unit Test
            Assert.AreEqual(new DateTime(2014, 04, 19, 23, 59, 59, 999), value);
        }
開發者ID:fqybzhangji,項目名稱:Z.ExtensionMethods,代碼行數:11,代碼來源:DateTime.EndOfWeek.cs

示例4: WeekEnd

        public void WeekEnd()
        {
            DateTime d = new DateTime(2010, 6, 15);
            Assert.AreEqual(new DateTime(2010, 6, 19), d.EndOfWeek());

            DateTime d1 = new DateTime(2010, 6, 15, 1, 2, 3);
            Assert.AreEqual(new DateTime(2010, 6, 19), d1.EndOfWeek());

            DateTime d2 = new DateTime(2010, 6, 20);
            Assert.AreEqual(new DateTime(2010, 6, 26), d2.EndOfWeek());

            DateTime d3 = new DateTime(2010, 7, 3);
            Assert.AreEqual(new DateTime(2010, 7, 3), d3.EndOfWeek());
        }
開發者ID:barake,項目名稱:TemporalToolkit,代碼行數:14,代碼來源:ExtensionTests.cs

示例5: GenerateSchedule

        public ScheduleViewModel GenerateSchedule(int userId, DateTime dateFrom, DateTime dateTo)
        {
            var user = DataProvider.Users.FirstOrDefault(p => p.Id == userId);
            if (user == null || (user.Prepod_PrepodMeta == null && user.Student_StudentMeta == null))
                return new ScheduleViewModel();

            List<IGrouping<DateTime, Raspisanie>> schedulesDateGroups;

            dateFrom = new DateTime(dateFrom.Year, dateFrom.Month, dateFrom.Day);
            dateTo = new DateTime(dateTo.Year, dateTo.Month, dateTo.Day);

            #region Правка даты

            if (dateTo.WeeksInYear() != dateFrom.WeeksInYear())
            {
                dateFrom = dateFrom.StartOfWeek(DayOfWeek.Monday);
                dateTo = dateTo.EndOfWeek(DayOfWeek.Saturday);
            }

            #endregion

            #region Условия для отбора данных из базы

            if (user.Prepod_PrepodMeta != null && user.Prepod_PrepodMeta.Any())
            {

                var prepodIds = DataProvider.PrepodiCafedri.Filter(p => p.Prepod_PrepodMeta.UserId == userId)
                                           .Select(p => p.Id);

                schedulesDateGroups = DataProvider.Raspisanie.Filter(p => prepodIds.Contains(p.IdPrepodaCafedri) && p.Data >= dateFrom && p.Data <= dateTo)

                                                 .GroupBy(p => p.Data)
                                                 .OrderBy(p => p.Key)
                                                 .ToList();

            }

            else
            {
                var userGroup = user.Student_StudentMeta.FirstOrDefault()
                                    .SostavGrupp.OrderByDescending(p => p.DateEdit)
                                               .FirstOrDefault();

                var flow = userGroup.SpisokGrupp.Pot;
                var groupId = userGroup.SpisokGrupp.IdGroup;
                var subGroup = userGroup.Podgroup;
                var specialityId = userGroup.SpisokGrupp.IdSpezMeta;
                //var formOfStudy = user.Student_StudentMeta.FirstOrDefault().FormOfStuduId;
                schedulesDateGroups = DataProvider.Raspisanie.Filter(p => p.Data >= dateFrom &&
                                                                           p.Data <= dateTo &&
                                                                           p.SpezialRazdeliDisziplini.IdSpezMeta == specialityId &&
                                                                           p.Pot == flow &&
                                                                           (!p.IdSpiskaGrupp.HasValue || p.IdSpiskaGrupp == groupId) &&
                                                                           (!p.NomerPodGrupp.HasValue || p.NomerPodGrupp == subGroup)
                                                                          )
                                                .GroupBy(p => p.Data)
                                                .OrderBy(p => p.Key)
                                                .ToList();
            }

            #endregion

            #region Отбор заметок

            var notifications = DataProvider.Notifications.Filter(p => userId == p.UserId && p.Date >= dateFrom && p.Date <= dateTo).ToList();

            #endregion

            var daysCount = (dateTo - dateFrom).Days + 1;

            var scheduleViewModel = new ScheduleViewModel()
            {
                DaysCount = daysCount,
                DateFrom = dateFrom.ToString("yyyy-MM-dd")
            };

            ScheduleWeekViewModel scheduleWeek = new ScheduleWeekViewModel();
            var scheduleDay = new ScheduleDayViewModel();
            var totalCount = schedulesDateGroups.Count;

            int maxLessonsInSimilarTime = 0;

            DateTime dateOfDay = new DateTime();
            List<string> lessonsTimes = new List<string>();

            #region Формируем расписание

            foreach (var schedulesDateGroup in schedulesDateGroups)
            {
                dateOfDay = schedulesDateGroup.Key;
                scheduleDay.DateOfDay = dateOfDay.ToString("yyyy-MM-dd");
                scheduleDay.IsCurrentDay = dateOfDay == DateTime.Now.Date;
                scheduleDay.IsPast = dateOfDay == DateTime.Now.Date;

                #region Добавляем уроки

                scheduleDay.Lessons = schedulesDateGroup.OrderBy(p => p.VremyaZanyatia.StartTime)
                                                   .Select(LessonViewModel.ToLessonViewModel)
                                                   .ToList();
                #endregion
//.........這裏部分代碼省略.........
開發者ID:gerasyana,項目名稱:Academy,代碼行數:101,代碼來源:ScheduleService.cs

示例6: EndOfWeekShouldReturnExpectedResult

 public void EndOfWeekShouldReturnExpectedResult()
 {
     var date = new DateTime( 2013, 3, 1 );
     var expected = new DateTime( 2013, 3, 2 );
     var actual = date.EndOfWeek();
     Assert.Equal( expected.Date, actual.Date );
 }
開發者ID:WaffleSquirrel,項目名稱:More,代碼行數:7,代碼來源:DateTimeExtensionsTest.cs

示例7: DateTimeEndOfWeek

 public void DateTimeEndOfWeek()
 {
     DateTime dt = new DateTime(2013, 2, 1);
     var end = dt.EndOfWeek(DayOfWeek.Monday);
     Assert.AreEqual(new DateTime(2013, 2, 5), end);
 }
開發者ID:niallduane,項目名稱:Yummy,代碼行數:6,代碼來源:ExtensionsTest.cs

示例8: GetWeeklySales

 public DataTable GetWeeklySales(int avdeling, DateTime date)
 {
     string sql = "SELECT * FROM " + TABLE_NAME + " WHERE " + KEY_AVDELING + " = " + avdeling
         + " AND CONVERT(NVARCHAR(10)," + KEY_DATO + ",121) >= CONVERT(NVARCHAR(10),'" + date.StartOfWeek().ToString("yyyy-MM-dd")
         + "',121) AND CONVERT(NVARCHAR(10)," + KEY_DATO + ",121) <= CONVERT(NVARCHAR(10),'" + date.EndOfWeek().ToString("yyyy-MM-dd") + "',121)";
     DataTable table = main.database.GetSqlDataTable(sql);
     if (table != null)
         table.Columns.Add("SalgsprisExMva", typeof(double), "Salgspris / Mva");
     return table;
 }
開發者ID:tborgund,項目名稱:kgsa,代碼行數:10,代碼來源:TableSalg.cs

示例9: EndOfWeek

        public static DateTime EndOfWeek( this Calendar calendar, DateTime date, DayOfWeek firstDayOfWeek )
        {
            Arg.NotNull( calendar, nameof( calendar ) );

            return date.EndOfWeek( firstDayOfWeek );
        }
開發者ID:WaffleSquirrel,項目名稱:More,代碼行數:6,代碼來源:CalendarExtensions.cs


注:本文中的System.DateTime.EndOfWeek方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。