本文整理汇总了C#中System.DateTime.LastDayOfMonth方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.LastDayOfMonth方法的具体用法?C# DateTime.LastDayOfMonth怎么用?C# DateTime.LastDayOfMonth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.LastDayOfMonth方法的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: 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());
}
示例3: Can_get_last_day_of_the_DateTime
public void Can_get_last_day_of_the_DateTime(int year, int month, int expectedLastDay)
{
var dateTime = new DateTime(year, month, 1);
var expectedDateTime = new DateTime(year, month, expectedLastDay);
var lastDayOfMonth = dateTime.LastDayOfMonth();
lastDayOfMonth.ShouldEqual(expectedDateTime);
}
示例4: 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);
}
示例5: LastDayOfMonthTest
public void LastDayOfMonthTest()
{
var today = new DateTime(2014, 4, 28);
today.LastDayOfMonth().ShouldEqual("30/04/2014");
}
示例6: LastDayOfMonthTest
public void LastDayOfMonthTest()
{
var date = new DateTime(2000, 2, 1);
var expected = new DateTime(2000, 2, 29);
var actual = date.LastDayOfMonth();
Assert.AreEqual(expected, actual);
}
示例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: last_day_of_month
public void last_day_of_month()
{
var date = new DateTime(2012, 6, 7);
date.LastDayOfMonth().ShouldEqual(new DateTime(2012, 6, 30).ToDate());
}
示例9: end_of_month_calcs_properly_mid_month_input
public void end_of_month_calcs_properly_mid_month_input()
{
var realLastDay = new DateTime(2012, 02, 29);
var today = new DateTime(2012, 02, 03);
today.LastDayOfMonth().ShouldEqual(realLastDay.ToDate());
}
示例10: LastDayOfMonth_Returns_Valid_Result
public void LastDayOfMonth_Returns_Valid_Result(DateTime date, DateTime expectedDate)
{
Assert.That(date.LastDayOfMonth(), Is.EqualTo(expectedDate));
}
示例11: NextDateAsOf
private DateTime NextDateAsOf(DateTime startDate, DateTime specificDate)
{
specificDate = specificDate.Date;
DateTime result = DateTime.MinValue;
if (this.Recurrence.Name == Recurrence.Weekly)
{
result = startDate;
while (result < specificDate)
{
result = result.AddDays(7);
}
}
else if (this.Recurrence.Name == Recurrence.Biweekly)
{
result = startDate;
while (result < specificDate)
{
result = result.AddDays(14);
}
}
else if (this.Recurrence.Name == Recurrence.Monthly)
{
result = startDate;
while (result < specificDate)
{
result = result.AddMonths(1);
}
}
else if (this.Recurrence.Name == Recurrence.Bimonthly)
{
result = startDate;
while (result < specificDate)
{
result = result.AddMonths(2);
}
}
else if (this.Recurrence.Name == Recurrence.LastDayOfMonth)
{
result = startDate.LastDayOfMonth();
while (result < specificDate)
{
result = result.AddMonths(1).LastDayOfMonth();
}
}
else if (this.Recurrence.Name == Recurrence.None && startDate >= specificDate)
{
result = startDate;
}
return result;
}
示例12: LastDayOfMonth
public void LastDayOfMonth()
{
var dateTime1 = new DateTime(2013, 3, 22);
var dateTime2 = new DateTime(2013, 2, 22);
var dateTime3 = new DateTime(2012, 2, 22);
var date1 = dateTime1.LastDayOfMonth();
var date2 = dateTime1.LastDayOfMonth(DayOfWeek.Monday);
var date3 = dateTime2.LastDayOfMonth();
var date4 = dateTime3.LastDayOfMonth();
Assert.AreEqual(new DateTime(2013, 3, 31), date1);
Assert.AreEqual(new DateTime(2013, 3, 25), date2);
Assert.AreEqual(new DateTime(2013, 2, 28), date3);
Assert.AreEqual(new DateTime(2012, 2, 29), date4);
}