Update of /cvsroot/nullabletypes/NullableTypes/src/Types
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29576/src/Types
Modified Files:
NullableDateTime.cs
Log Message:
Change the behaviour of NullableDateTime.Add to return a new NullableDateTime in line with .Subtract, +, - and DateTime as per issue 1281536.
Also added missing .Add and .Subtract method unit tests.
Index: NullableDateTime.cs
===================================================================
RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableDateTime.cs,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** NullableDateTime.cs 20 Feb 2004 00:42:22 -0000 1.21
--- NullableDateTime.cs 23 Sep 2005 12:06:22 -0000 1.22
***************
*** 27,30 ****
--- 27,32 ----
// other types in NullableTypes
// 18-Feb-2004 Luca Bug Fix ReadXml must read nil value also with a non empty element
+ // 23-Sep-2005 DamienG Change Change the .Add method to return a new NullableDateTime structure and not
+ // modify this one, as is consistent with DateTime.
//
***************
*** 436,449 ****
/// <summary>
! /// Adds a specified time interval to this structure.
/// </summary>
/// <param name="t">A System.TimeSpan</param>
! public void Add(sys.TimeSpan t) {
! if (_notNull)
! _value += t;
}
/// <summary>
! /// Subtracts a specified time interval to this structure.
/// </summary>
/// <param name="t">A System.TimeSpan</param>
--- 438,461 ----
/// <summary>
! /// Adds a specified time interval to this date and time in this structure
! /// yielding a new date and time.
/// </summary>
/// <param name="t">A System.TimeSpan</param>
! /// <returns>
! /// A NullableDateTime that is the sum of this structure and <paramref name="t"/>.
! /// </returns>
! /// <remarks>
! /// This method does not change the value of this NullableDateTime. Instead, a new NullableDateTime
! /// is returned whose value is the result of this operation.
! /// </remarks>
! public NullableDateTime Add(sys.TimeSpan t) {
! if (IsNull)
! return NullableDateTime.Null;
! return new NullableDateTime(_value + t);
}
/// <summary>
! /// Subtracts a specified time interval from the date and time in this structure
! /// yielding a new date and time.
/// </summary>
/// <param name="t">A System.TimeSpan</param>
|