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


C# DateTime.FirstDayOfMonth方法代码示例

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


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

示例1: ComputeMonthlyRevenue

        public MonthlyRevenue ComputeMonthlyRevenue(string branchName, int year, int month)
        {
            var dateTime = new DateTime(year, month, 1);

            var oneTimeGames = gameRepository
                            .GetGames(branchName, dateTime.FirstDayOfMonth(), dateTime.LastDayOfMonth())
                            .Where(game => game.GamePaymentType == GamePaymentType.OneTime)
                            .ToList();

            var packageGames = oneTimeGames.Where(game => game.PackageType != PackageType.No_Package);
            var nonPackageGames = oneTimeGames.Where(game => game.PackageType == PackageType.No_Package);

            var membershipReCharges = membershipRepository.GetRecharges(branchName, dateTime.FirstDayOfMonth(), dateTime.LastDayOfMonth()).ToList();

            return new MonthlyRevenue
                       {
                           DateTime = dateTime,
                           NonMembershipGamesCount = oneTimeGames.Count,
                           MembershipRechargesCount = membershipReCharges.Count,
                           RevenueByNonPackageOneTimeGames = nonPackageGames.Sum(game => game.Price),
                           RevenueByPackageOneTimeGames = packageGames.Sum(game => game.Price),
                           RevenueByMembershipRecharges = membershipReCharges.Sum(recharge => recharge.Price),
                           EbMeterReading = dailySaleDetailsRepository.GetEbMeterReadingForTheMonth(branchName, year, month),
                           MonthlyExpense = monthlyExpensesRepository.GetMonthlyExpenses(branchName, month, year)
                       };
        }
开发者ID:tamizhvendan,项目名称:gameo,代码行数:26,代码来源:RevenueService.cs

示例2: FirstDayOfMonth

        public void FirstDayOfMonth()
        {
            var dateTime1 = new DateTime(2013, 3, 22);
            var date1 = dateTime1.FirstDayOfMonth();
            var date2 = dateTime1.FirstDayOfMonth(DayOfWeek.Monday);

            Assert.AreEqual(new DateTime(2013, 3, 1), date1);
            Assert.AreEqual(new DateTime(2013, 3, 4), date2);
        }
开发者ID:adrianocaldeira,项目名称:thunder,代码行数:9,代码来源:DateTimeExtensionsTest.cs

示例3: FirstDayOfMonthTest

 public void FirstDayOfMonthTest()
 {
     var date = new DateTime(2000, 1, 31, 23, 59, 59, 999);
     var expected = new DateTime(2000, 1, 1);
     var actual = date.FirstDayOfMonth();
     Assert.AreEqual(expected, actual);
 }
开发者ID:jonathascosta,项目名称:SystemExtensions,代码行数:7,代码来源:DateTimeExtensionsFixture.cs

示例4: eom_as_input_calcs_begin_and_end_properly

 public void eom_as_input_calcs_begin_and_end_properly()
 {
     var realLastDay = new DateTime(2012, 02, 29);
     var realFirstDay = new DateTime(2012, 02, 01);
     var today = new DateTime(2012, 02, 29);
     today.LastDayOfMonth().ShouldEqual(realLastDay.ToDate());
     today.FirstDayOfMonth().ShouldEqual(realFirstDay.ToDate());
 }
开发者ID:rasupit,项目名称:fubucore,代码行数:8,代码来源:DateTimeExtensionTester.cs

示例5: FullMonthToAViewFor

        public static FullMonthToAView FullMonthToAViewFor(DateTime dateTime, IDocumentSession session)
        {
            var firstDayOfMonth = dateTime.FirstDayOfMonth();
            var weekDayOfFirstDayOfMonth = firstDayOfMonth.DayOfWeek;
            var firstDateToFind = firstDayOfMonth;
            if (weekDayOfFirstDayOfMonth == DayOfWeek.Tuesday)
                firstDateToFind = firstDayOfMonth.AddDays(-1);
            if (weekDayOfFirstDayOfMonth == DayOfWeek.Wednesday)
                firstDateToFind = firstDayOfMonth.AddDays(-2);
            if (weekDayOfFirstDayOfMonth == DayOfWeek.Thursday)
                firstDateToFind = firstDayOfMonth.AddDays(-3);
            if (weekDayOfFirstDayOfMonth == DayOfWeek.Friday)
                firstDateToFind = firstDayOfMonth.AddDays(-4);
            if (weekDayOfFirstDayOfMonth == DayOfWeek.Saturday)
                firstDateToFind = firstDayOfMonth.AddDays(-5);
            if (weekDayOfFirstDayOfMonth == DayOfWeek.Sunday)
                firstDateToFind = firstDayOfMonth.AddDays(-6);

            var lastDayOfMonth = dateTime.LastDayOfMonth();
            var weekDayOfLastDayOfMonth = lastDayOfMonth.DayOfWeek;
            var lastDateToFind = lastDayOfMonth;
            if (weekDayOfLastDayOfMonth == DayOfWeek.Monday)
                lastDateToFind = lastDayOfMonth.AddDays(6);
            if (weekDayOfLastDayOfMonth == DayOfWeek.Tuesday)
                lastDateToFind = lastDayOfMonth.AddDays(5);
            if (weekDayOfLastDayOfMonth == DayOfWeek.Wednesday)
                lastDateToFind = lastDayOfMonth.AddDays(4);
            if (weekDayOfLastDayOfMonth == DayOfWeek.Thursday)
                lastDateToFind = lastDayOfMonth.AddDays(3);
            if (weekDayOfLastDayOfMonth == DayOfWeek.Friday)
                lastDateToFind = lastDayOfMonth.AddDays(2);
            if (weekDayOfLastDayOfMonth == DayOfWeek.Saturday)
                lastDateToFind = lastDayOfMonth.AddDays(1);

            var bookings = session.Advanced.LuceneQuery<Booking>()
                .WhereBetweenOrEqual(x => x.Date, firstDateToFind, lastDateToFind)
                .ToList();
            return new FullMonthToAView(bookings, firstDateToFind, lastDateToFind);
        }
开发者ID:RHMGLtd,项目名称:sourcecode,代码行数:39,代码来源:DiaryManager.cs

示例6: FirstDayOfMonthTest

 public void FirstDayOfMonthTest()
 {
     var today = new DateTime(2014, 4, 28);
     today.FirstDayOfMonth().ShouldEqual("01/04/2014");
 }
开发者ID:drbatty,项目名称:c-sharp-extensions,代码行数:5,代码来源:DateTimeExtensionsTests.cs

示例7: Range

		public static CalendarRange Range(
			DateTime date,
			CalendarView vista,
			DayOfWeek firstDayOfWeek = DayOfWeek.Monday,
			DayOfWeek lastDayOfWeek = DayOfWeek.Sunday)
		{
			var selectedDate = date.Date;

			var firstDay = selectedDate.FirstDayOfWeek();

			if (vista == CalendarView.Day)
			{
				firstDay = date;
			}

			if (vista != CalendarView.Month)
			{
				var dates =
					Enumerable
						.Range(0, (int)vista)
						.Select(dayCount => firstDay.AddDays(dayCount))
						.ToList();

				return new CalendarRange(dates.First(), dates.Last());
			}

			var firstDayOfMonth = date.FirstDayOfMonth();
			var first = firstDayOfMonth.FirstDayOfWeek(firstDayOfWeek);

			var lastDayOfMonth = date.LastDayOfMonth();
			var last = lastDayOfMonth.LastDayOfWeek(lastDayOfWeek);

			return new CalendarRange(first, last);
		}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:34,代码来源:Scheduling.cs

示例8: middle_of_month_input_has_proper_first_day_of_month

 public void middle_of_month_input_has_proper_first_day_of_month()
 {
     var realFirstDay = new DateTime(2012, 02, 01);
     var today = new DateTime(2012, 02, 03);
     today.FirstDayOfMonth().ShouldEqual(realFirstDay.ToDate());
 }
开发者ID:rasupit,项目名称:fubucore,代码行数:6,代码来源:DateTimeExtensionTester.cs

示例9: first_day_of_month_for_date_is_same

 public void first_day_of_month_for_date_is_same()
 {
     var today = new DateTime(2012, 02, 01);
     today.FirstDayOfMonth().ShouldEqual(today.ToDate());
 }
开发者ID:rasupit,项目名称:fubucore,代码行数:5,代码来源:DateTimeExtensionTester.cs

示例10: first_day_of_month

 public void first_day_of_month()
 {
     var date = new DateTime(2012, 6, 7);
     date.FirstDayOfMonth().ShouldEqual(new DateTime(2012, 6, 1).ToDate());
 }
开发者ID:rasupit,项目名称:fubucore,代码行数:5,代码来源:DateTimeExtensionTester.cs

示例11: FirstDayOfMonth_Returns_Valid_Result

 public void FirstDayOfMonth_Returns_Valid_Result(DateTime date, DateTime expectedDate)
 {
     Assert.That(date.FirstDayOfMonth(), Is.EqualTo(expectedDate));
 }
开发者ID:akordowski,项目名称:NToolbox,代码行数:4,代码来源:DateTimeExtensionTest.cs

示例12: _GetNextFromExact

 protected override DateTime? _GetNextFromExact(DateTime knownGood)
 {
     return GetDayInMonth(knownGood.FirstDayOfMonth().AddMonths(Interval));
 }
开发者ID:sourceit,项目名称:Recurrency.net,代码行数:4,代码来源:MonthlyRecurrency.cs


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