本文整理汇总了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)
};
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例6: FirstDayOfMonthTest
public void FirstDayOfMonthTest()
{
var today = new DateTime(2014, 4, 28);
today.FirstDayOfMonth().ShouldEqual("01/04/2014");
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
示例11: FirstDayOfMonth_Returns_Valid_Result
public void FirstDayOfMonth_Returns_Valid_Result(DateTime date, DateTime expectedDate)
{
Assert.That(date.FirstDayOfMonth(), Is.EqualTo(expectedDate));
}
示例12: _GetNextFromExact
protected override DateTime? _GetNextFromExact(DateTime knownGood)
{
return GetDayInMonth(knownGood.FirstDayOfMonth().AddMonths(Interval));
}