コード例 #1
0
        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));
        }
コード例 #2
0
 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 );
 }
コード例 #3
0
 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 );
 }
コード例 #4
0
ファイル: msYear.cs プロジェクト: pdesterlich/msUtilities
 /// <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
 }
コード例 #5
0
        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);
        }
コード例 #6
0
 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 );
 }
コード例 #7
0
 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 );
 }
コード例 #8
0
        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 );
        }