2 // Mono.Data.TdsTypes.TdsDateTime
5 // Tim Coleman <tim@timcoleman.com>
7 // (C) Copyright Tim Coleman, 2002
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using Mono.Data.TdsClient;
33 using System.Data.SqlTypes;
34 using System.Globalization;
36 namespace Mono.Data.TdsTypes {
37 public struct TdsDateTime : INullable, IComparable
40 private DateTime value;
43 public static readonly TdsDateTime MaxValue = new TdsDateTime (9999,12,31);
44 public static readonly TdsDateTime MinValue = new TdsDateTime (1753,1,1);
45 public static readonly TdsDateTime Null;
46 public static readonly int SQLTicksPerHour;
47 public static readonly int SQLTicksPerMinute;
48 public static readonly int SQLTicksPerSecond;
54 public TdsDateTime (DateTime value)
61 public TdsDateTime (int dayTicks, int timeTicks)
63 throw new NotImplementedException ();
66 public TdsDateTime (int year, int month, int day)
68 this.value = new DateTime (year, month, day);
72 public TdsDateTime (int year, int month, int day, int hour, int minute, int second)
74 this.value = new DateTime (year, month, day, hour, minute, second);
79 public TdsDateTime (int year, int month, int day, int hour, int minute, int second, double millisecond)
81 throw new NotImplementedException ();
85 public TdsDateTime (int year, int month, int day, int hour, int minute, int second, int bilisecond)
87 throw new NotImplementedException ();
96 get { throw new NotImplementedException (); }
100 get { return !notNull; }
104 public int TimeTicks {
105 get { throw new NotImplementedException (); }
108 public DateTime Value {
111 throw new TdsNullValueException ("The property contains Null.");
121 public int CompareTo (object value)
125 else if (!(value is TdsDateTime))
126 throw new ArgumentException (Locale.GetText ("Value is not a System.Data.TdsTypes.TdsDateTime"));
127 else if (((TdsDateTime)value).IsNull)
130 return this.value.CompareTo (((TdsDateTime)value).Value);
133 public override bool Equals (object value)
135 if (!(value is TdsDateTime))
138 return (bool) (this == (TdsDateTime)value);
141 public static TdsBoolean Equals (TdsDateTime x, TdsDateTime y)
147 public override int GetHashCode ()
152 public static TdsBoolean GreaterThan (TdsDateTime x, TdsDateTime y)
157 public static TdsBoolean GreaterThanOrEqual (TdsDateTime x, TdsDateTime y)
162 public static TdsBoolean LessThan (TdsDateTime x, TdsDateTime y)
167 public static TdsBoolean LessThanOrEqual (TdsDateTime x, TdsDateTime y)
172 public static TdsBoolean NotEquals (TdsDateTime x, TdsDateTime y)
178 public static TdsDateTime Parse (string s)
180 throw new NotImplementedException ();
183 public TdsString ToTdsString ()
185 return ((TdsString)this);
188 public override string ToString ()
193 return value.ToString ();
197 public static TdsDateTime operator + (TdsDateTime x, TimeSpan t)
199 throw new NotImplementedException ();
202 public static TdsBoolean operator == (TdsDateTime x, TdsDateTime y)
204 if (x.IsNull || y.IsNull)
205 return TdsBoolean.Null;
207 return new TdsBoolean (x.Value == y.Value);
210 public static TdsBoolean operator > (TdsDateTime x, TdsDateTime y)
212 if (x.IsNull || y.IsNull)
213 return TdsBoolean.Null;
215 return new TdsBoolean (x.Value > y.Value);
218 public static TdsBoolean operator >= (TdsDateTime x, TdsDateTime y)
220 if (x.IsNull || y.IsNull)
221 return TdsBoolean.Null;
223 return new TdsBoolean (x.Value >= y.Value);
226 public static TdsBoolean operator != (TdsDateTime x, TdsDateTime y)
228 if (x.IsNull || y.IsNull)
229 return TdsBoolean.Null;
231 return new TdsBoolean (!(x.Value == y.Value));
234 public static TdsBoolean operator < (TdsDateTime x, TdsDateTime y)
236 if (x.IsNull || y.IsNull)
237 return TdsBoolean.Null;
239 return new TdsBoolean (x.Value < y.Value);
242 public static TdsBoolean operator <= (TdsDateTime x, TdsDateTime y)
244 if (x.IsNull || y.IsNull)
245 return TdsBoolean.Null;
247 return new TdsBoolean (x.Value <= y.Value);
251 public static TdsDateTime operator - (TdsDateTime x, TimeSpan t)
253 throw new NotImplementedException ();
256 public static explicit operator DateTime (TdsDateTime x)
262 public static explicit operator TdsDateTime (TdsString x)
264 throw new NotImplementedException();
267 public static implicit operator TdsDateTime (DateTime x)
269 return new TdsDateTime (x);