当前位置: 首页>>代码示例>>C#>>正文


C# DateTime.StartOfWeek方法代码示例

本文整理汇总了C#中System.DateTime.StartOfWeek方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.StartOfWeek方法的具体用法?C# DateTime.StartOfWeek怎么用?C# DateTime.StartOfWeek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.DateTime的用法示例。


在下文中一共展示了DateTime.StartOfWeek方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestStartOfWeek

        public void TestStartOfWeek()
        {
            DateTime dt = new DateTime(2014, 3, 13);
            Assert.AreEqual(new DateTime(2014, 3, 10), dt.StartOfWeek(DayOfWeek.Monday));
            Assert.AreEqual(new DateTime(2014, 3, 9), dt.StartOfWeek(DayOfWeek.Sunday));

            DateTime dt2 = new DateTime(2016, 5, 1);
            Assert.AreEqual(new DateTime(2016, 4, 30), dt2.StartOfWeek(DayOfWeek.Saturday));
        }
开发者ID:Guzzter,项目名称:GBUtils,代码行数:9,代码来源:DateTimeExtensionTest.cs

示例2: StartOfWeekWithCustomDayOfWeekShouldReturnExpectedResult

        public void StartOfWeekWithCustomDayOfWeekShouldReturnExpectedResult()
        {
            var date = new DateTime( 2013, 3, 1 );
            var expected = new DateTime( 2013, 2, 24 );
            var actual = date.StartOfWeek( DayOfWeek.Sunday );
            Assert.Equal( expected.Date, actual.Date );

            expected = new DateTime( 2013, 2, 25 );
            actual = date.StartOfWeek( DayOfWeek.Monday );
            Assert.Equal( expected.Date, actual.Date );
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:11,代码来源:DateTimeExtensionsTest.cs

示例3: StartOfWeekTestCase

        public void StartOfWeekTestCase()
        {
            var dateTime = new DateTime( 2014, 3, 27 );
            var expected = new DateTime( 2014, 3, 24 );
            var actual = dateTime.StartOfWeek();

            Assert.AreEqual( expected, actual );

            expected = new DateTime( 2014, 3, 26 );
            actual = dateTime.StartOfWeek( DayOfWeek.Wednesday );

            Assert.AreEqual( expected, actual );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:13,代码来源:DateTime.StartOfWeek.Test.cs

示例4: GroupNotes

        public GroupNotes()
        {
            InitializeComponent();
            admin = false;

            String query = "select ClientNum, ClientName from ClientInfo where IntakeDate not like '0001-01-01%' and ExitDate like '0001-01-01%'";
            clients = database.GetTable(query);

            editingDay = DateTime.Now;
            lastDayOfWeek = editingDay.Next(DayOfWeek.Sunday);
            firstDayOfWeek = editingDay.StartOfWeek(DayOfWeek.Monday);
            dayOfWeek = editingDay.DayOfWeek.ToString();
            WeekOf_Label.Text = "Week of " + firstDayOfWeek.ToString("MM/dd") + " through " + lastDayOfWeek.ToString("MM/dd");

            updateClientList();
            clientList.SetSelected(0, true);

            newPDFPath = "/clientfiles/groupnotes/" + loadClientID + "/"; // C:\\Users/Darryl/SparkleShare/WestSlopeSecure
            newFile = newPDFPath + firstDayOfWeek.ToString("MM-dd-yyyy") + ".pdf";
            templatePathFromOld = newPDFPath + firstDayOfWeek.ToString("MM-dd-yyyy") + "-old.pdf";

            // Wipe out shit files.
            if (Directory.Exists(newPDFPath))
            {
                foreach (var file in Directory.EnumerateFiles(newPDFPath, "*-old.pdf", SearchOption.TopDirectoryOnly))
                    File.Delete(file);
            }

            processPdfGen();
            DaySelection.SelectedIndex = ((int)(editingDay.DayOfWeek) + 6) % 7;
        }
开发者ID:KristopherTadlock,项目名称:wsrsmooz,代码行数:31,代码来源:GroupNotes.cs

示例5: checkForTimesheet

        public void checkForTimesheet(string userName, DateTime tsDate)
        {
            Authentication auth = new Authentication();
            if (auth.isUser(this) || Authentication.DEBUG_bypassAuth)
            {
                Timesheet resulttimesheet = new Timesheet();
                DateTime startDay = tsDate.StartOfWeek(DayOfWeek.Sunday);

                //Check if there is a timesheet for the week that corresponds to newhours.timestamp
                var searchTs = from m in TimesheetDB.TimesheetList
                               where (m.worker.CompareTo(userName) == 0)
                               where m.periodStart <= tsDate
                               where m.periodEnd >= tsDate
                               select m;
                foreach (var item in searchTs)
                {
                    resulttimesheet = item;
                }

                //if there isn't a timesheet for the pay period, then create one
                //If there is a timesheet for the current pay period, don't do anything
                if (resulttimesheet.periodStart.CompareTo(startDay) != 0)
                {
                    createTimesheet(userName, startDay);
                    return;
                }
                return;
            }
            else
            {
                return;
            }
        }
开发者ID:ICBM,项目名称:TARS,代码行数:33,代码来源:UserController.cs

示例6: StartOfWeekShouldReturnExpectedResult

 public void StartOfWeekShouldReturnExpectedResult()
 {
     var date = new DateTime( 2013, 3, 1 );
     var expected = new DateTime( 2013, 2, 24 );
     var actual = date.StartOfWeek();
     Assert.Equal( expected.Date, actual.Date );
 }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:7,代码来源:DateTimeExtensionsTest.cs

示例7: StartOfWeekTestCase2

        public void StartOfWeekTestCase2()
        {
            var week = new DateTime( 2014, 09, 21 );
            var expected = new DateTime( 2014, 09, 20 );
            var actual = week.StartOfWeek( DayOfWeek.Saturday );

            Assert.AreEqual( expected, actual );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:8,代码来源:DateTime.StartOfWeek.Test.cs

示例8: StartOfWeek

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

            // Examples
            DateTime value = @this.StartOfWeek(); // value = "2013/04/13 00:00:00:000";

            // Unit Test
            Assert.AreEqual(new DateTime(2014, 04, 13), value);
        }
开发者ID:ChuangYang,项目名称:Z.ExtensionMethods,代码行数:11,代码来源:DateTime.StartOfWeek.cs

示例9: DateTimeHelper

        public DateTimeHelper()
        {
            _now = DateTime.Now;
            _todayStartDate = _now.Hour < 4
                ? new DateTime(_now.Year, _now.Month, _now.Day, 4, 0, 0).AddDays(-1)
                : new DateTime(_now.Year, _now.Month, _now.Day, 4, 0, 0);

            _todayEndDate = _todayStartDate.AddHours(24);
            NextDay = _todayEndDate;

            _weekStartDate = _now.StartOfWeek(DayOfWeek.Monday).AddHours(4);
            _weekEndDate = _weekStartDate.AddDays(7);
            NextWeek = _weekEndDate;
        }
开发者ID:Alkalinee,项目名称:GamerJail,代码行数:14,代码来源:DateTimeHelper.cs

示例10: CreateTasksForWeek

 public IEnumerable<Task> CreateTasksForWeek(DateTime week)
 {
     var tasks = new List<Task>();
     DateTime weekStart = week.StartOfWeek(DayOfWeek.Monday);
     for (var day = weekStart; (day - weekStart).Days < 7; day = day.AddDays(1))
     {
         if (IncludesDay(day)) tasks.Add(new Task {
             ActivityId = Activity.ActivityId,
             Activity = Activity,
             Start = day,
             Finished = false
         });
     }
     return tasks;
 }
开发者ID:johanhelsing,项目名称:vaskelista,代码行数:15,代码来源:ScheduleItem.cs

示例11: GetMemberAttendanceObject

        private MemberAttendanceForView GetMemberAttendanceObject(Attendance attendance, List<MemberAttendance> memberAttendances, DateTime weekRequested)
        {
            var mondayDate = weekRequested.StartOfWeek(DayOfWeek.Monday); // DateTime.Now.StartOfWeek(DayOfWeek.Monday);

            return new MemberAttendanceForView
            {
                Attendance = attendance,
                AttendanceId = attendance.AttendanceId,
                MemberAttendances = memberAttendances,
                Projects = _unitOfWork.ProjectRepository.Get().ToList(),
                MondayDate = mondayDate.ToShortDateString(),
                TuesdayDate = mondayDate.AddDays(1).ToShortDateString(),
                WednesdayDate = mondayDate.AddDays(2).ToShortDateString(),
                ThursdayDate = mondayDate.AddDays(3).ToShortDateString(),
                FridayDate = mondayDate.AddDays(4).ToShortDateString(),
                SaturdayDate = mondayDate.AddDays(5).ToShortDateString(),
                SundayDate = mondayDate.AddDays(6).ToShortDateString()
            };
        }
开发者ID:whztt07,项目名称:SmartDb4,代码行数:19,代码来源:AttendanceController.cs

示例12: GetLastStartWeek

 private DateTime GetLastStartWeek(DateTime lastStart)
 {
     return lastStart.StartOfWeek(DayOfWeek.Monday).AddDays(7).Add(GetLeagueStartTimeSpan());
 }
开发者ID:Exploseph,项目名称:BowlingAPI,代码行数:4,代码来源:BowlingJackpotRepository.cs

示例13: userManagement

        //
        /* Retrieves all the employee objects of employees that work for the specified departement 
         * within the Information Technology division (as per client request), then returns them
         * as a list. If department is null, it displays all employees in the division
         */
        public virtual ActionResult userManagement(DateTime refDate, string department = null)
        {
            Authentication auth = new Authentication();
            if (auth.isManager(this) || Authentication.DEBUG_bypassAuth)
            {
                //if it's a redirect from submitRejectTimesheet()
                if (TempData["emailSentFlag"] != null)
                {
                    ViewBag.emailSentFlag = true;
                    ViewBag.messageRecipient = TempData["recipient"];
                }

                string division = getUserDivision();
                IEnumerable<TARSUser> employees = getDivisionEmployeeObjList(division, department);
                ViewBag.division = division;
                ViewBag.departmentList = getDepartmentSelectList(division);
                ViewBag.refDate = refDate;
                ViewBag.refSunday = refDate.StartOfWeek(DayOfWeek.Sunday);
                ViewBag.refPayPeriod = getPayPeriod(refDate);
                return View(employees);
            }
            else
            {
                return View("error");
            }
        }
开发者ID:zekelong,项目名称:TimeAccountingAndReportingSystem,代码行数:31,代码来源:ManagerController.cs

示例14: GivenADateTimeThenReturnThePreviousMondayDateTime

 public void GivenADateTimeThenReturnThePreviousMondayDateTime(DateTime dateTime, DateTime answer)
 {
     var startOfWeek = dateTime.StartOfWeek();
     Assert.AreEqual(startOfWeek, answer);
 }
开发者ID:prinzo,项目名称:Attack-Of-The-Fines-TA15,代码行数:5,代码来源:DateTimeExtensionsTests.cs

示例15: getPayPeriod

 // 
 //Returns the pay period for the reference date as a string
 public virtual string getPayPeriod(DateTime refDate)
 {
     DateTime startDay = refDate.StartOfWeek(DayOfWeek.Sunday);
     DateTime endDay = startDay.AddDays(6);
     string payPeriod = startDay.ToShortDateString() + " - " + endDay.ToShortDateString();
     return payPeriod;
 }
开发者ID:zekelong,项目名称:TimeAccountingAndReportingSystem,代码行数:9,代码来源:UserController.cs


注:本文中的System.DateTime.StartOfWeek方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。