From: Michael D. <mik...@us...> - 2004-11-03 03:37:19
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10534/NHibernate/Type Modified Files: TimeType.cs Log Message: Moved TimeType to its own test classes in the NHSpecific area and out of the ported classes. MySql does not follow the DbType.Time docs so this will help to isolate failing tests to just that datatype. Index: TimeType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TimeType.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TimeType.cs 19 Oct 2004 02:24:08 -0000 1.7 --- TimeType.cs 3 Nov 2004 03:37:06 -0000 1.8 *************** *** 7,19 **** /// <summary> ! /// Maps a System.DateTime Property to an DateTime column that only stores the Hours, Minutes, ! /// and Seconds of the DateTime. /// </summary> /// <remarks> ! /// This defaults the Year to 0001, the Month to 01, and the Day to 01 - that should not matter because /// using this Type indicates that you don't care about the Date portion of the DateTime. /// </remarks> public class TimeType : ValueTypeType, IIdentifierType, ILiteralType { internal TimeType() : base( new TimeSqlType() ) { --- 7,28 ---- /// <summary> ! /// Maps a <see cref="System.DateTime" /> Property to an DateTime column that only stores the ! /// Hours, Minutes, and Seconds of the DateTime as significant. /// </summary> /// <remarks> ! /// <para> ! /// This defaults the Date to "1753-01-01" - that should not matter because /// using this Type indicates that you don't care about the Date portion of the DateTime. + /// </para> + /// <para> + /// A more appropriate choice to store the duration/time is the <see cref="TimeSpanType"/>. + /// The underlying <see cref="DbType.Time"/> tends to be handled diffently by different + /// DataProviders. + /// </para> /// </remarks> public class TimeType : ValueTypeType, IIdentifierType, ILiteralType { + private static DateTime BaseDateValue = new DateTime( 1753, 01, 01 ); + internal TimeType() : base( new TimeSqlType() ) { *************** *** 23,27 **** { DateTime dbValue = Convert.ToDateTime(rs[index]); ! return new DateTime(1, 1, 1, dbValue.Hour, dbValue.Minute, dbValue.Second); } --- 32,36 ---- { DateTime dbValue = Convert.ToDateTime(rs[index]); ! return new DateTime(1753, 01, 01, dbValue.Hour, dbValue.Minute, dbValue.Second); } *************** *** 39,43 **** { IDataParameter parm = st.Parameters[index] as IDataParameter; ! if((DateTime)value<new DateTime(1753,1,1)) { parm.Value = DBNull.Value; --- 48,52 ---- { IDataParameter parm = st.Parameters[index] as IDataParameter; ! if( (DateTime)value < TimeType.BaseDateValue ) { parm.Value = DBNull.Value; |