本文整理汇总了C#中System.DateTime.EndOfYear方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.EndOfYear方法的具体用法?C# DateTime.EndOfYear怎么用?C# DateTime.EndOfYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.EndOfYear方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EndOfYearTestCase2
public void EndOfYearTestCase2()
{
var dateTime = new DateTime( 9999, 12, 31 );
var expected = new DateTime( 9999, 12, 31, 23, 59, 59, 999 );
var actual = dateTime.EndOfYear();
Assert.AreEqual( expected, actual );
}
示例2: EndOfYearTestCase1
public void EndOfYearTestCase1()
{
var dateTime = new DateTime( 1, 1, 1 );
var expected = new DateTime( dateTime.Year, 1, 1 ).AddYears( 1 )
.Subtract( 1.ToMilliseconds() );
var actual = dateTime.EndOfYear();
Assert.AreEqual( expected, actual );
}
示例3: MsYear
/// <summary>
/// creates a new msYear object for the year containing the date
/// </summary>
/// <param name="date">date within the year</param>
public MsYear(DateTime date)
{
#if NET20
StartDate = MsDateHelpers.StartOfYear(date);
EndDate = MsDateHelpers.EndOfYear(date);
#else
StartDate = date.StartOfYear();
EndDate = date.EndOfYear();
#endif
}
示例4: EndOfYear
public void EndOfYear()
{
// Type
var @this = new DateTime(2013, 04, 13);
// Examples
DateTime value = @this.EndOfYear(); // value = "2013/12/31 23:59:59:999";
// Unit Test
Assert.AreEqual(new DateTime(2013, 12, 31, 23, 59, 59, 999), value);
}
示例5: EndOfYearWithCalendarShouldReturnExpectedResult
public void EndOfYearWithCalendarShouldReturnExpectedResult()
{
var date = new DateTime( 2013, 3, 1 );
var calendar = new GregorianFiscalCalendar( 7 );
var expected = new DateTime( 2013, 6, 30 ); // because fiscal calendar starts in July
var actual = date.EndOfYear( calendar );
Assert.Equal( expected.Date, actual.Date );
}
示例6: EndOfYearShouldReturnExpectedResult
public void EndOfYearShouldReturnExpectedResult()
{
var date = new DateTime( 2013, 3, 1 );
var expected = new DateTime( 2013, 12, 31 );
var actual = date.EndOfYear();
Assert.Equal( expected.Date, actual.Date );
}
示例7: EndOfYear
public static DateTime EndOfYear( this Calendar calendar, DateTime date )
{
Arg.NotNull( calendar, nameof( calendar ) );
Contract.Ensures( calendar.GetYear( Contract.Result<DateTime>() ) == Contract.OldValue( calendar.GetYear( date ) ) );
return date.EndOfYear( calendar );
}