当前位置: 首页>>代码示例>>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;未经允许,请勿转载。