public void TestEndOfYear() { var wellKnownYear1 = new DateTime(2009, 12, 31); var endOfWellKnownYear1 = new DateTime(2009, 12, 31); var wellKnownYear2 = new DateTime(2007, 12, 31); var endOfWellKnownYear2 = new DateTime(2007, 12, 31); Assert.IsTrue(wellKnownYear1.EndOfYear().Equals(endOfWellKnownYear1)); Assert.IsTrue(wellKnownYear2.EndOfYear().Equals(endOfWellKnownYear2)); Assert.IsFalse(wellKnownYear1.EndOfYear().Equals(endOfWellKnownYear2)); Assert.IsFalse(wellKnownYear2.EndOfYear().Equals(endOfWellKnownYear1)); }
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 ); }
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 ); }
/// <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 }
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); }
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 ); }
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 ); }
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 ); }