4 // Part of the Mono class libraries at
5 // mcs/class/System.Data.OracleClient/System.Data.OracleClient
7 // Assembly: System.Data.OracleClient.dll
8 // Namespace: System.Data.OracleClient
10 // Author: Tim Coleman <tim@timcoleman.com>
12 // Copyright (C) Tim Coleman, 2003
14 // Licensed under the MIT/X11 License.
18 using System.Data.SqlTypes;
19 using System.Globalization;
21 namespace System.Data.OracleClient {
22 public struct OracleDateTime : IComparable, INullable
26 public static readonly OracleDateTime MaxValue = new OracleDateTime (4712, 12, 31);
27 public static readonly OracleDateTime MinValue = new OracleDateTime (1, 1, 1);
28 public static readonly OracleDateTime Null = new OracleDateTime ();
37 public OracleDateTime (DateTime dt)
43 public OracleDateTime (long ticks)
44 : this (new DateTime (ticks))
48 public OracleDateTime (OracleDateTime from)
53 public OracleDateTime (int year, int month, int day)
54 : this (new DateTime (year, month, day))
58 public OracleDateTime (int year, int month, int day, Calendar calendar)
59 : this (new DateTime (year, month, day, calendar))
63 public OracleDateTime (int year, int month, int day, int hour, int minute, int second)
64 : this (new DateTime (year, month, day, hour, minute, second))
68 public OracleDateTime (int year, int month, int day, int hour, int minute, int second, Calendar calendar)
69 : this (new DateTime (year, month, day, hour, minute, second, calendar))
73 public OracleDateTime (int year, int month, int day, int hour, int minute, int second, int millisecond)
74 : this (new DateTime (year, month, day, hour, minute, second, millisecond))
78 public OracleDateTime (int year, int month, int day, int hour, int minute, int second, int millisecond, Calendar calendar)
79 : this (new DateTime (year, month, day, hour, minute, second, millisecond, calendar))
83 #endregion // Constructors
88 get { return value.Day; }
92 get { return value.Hour; }
96 get { return !notNull; }
99 public int Millisecond {
100 get { return value.Millisecond; }
104 get { return value.Minute; }
108 get { return value.Month; }
112 get { return value.Second; }
115 public DateTime Value {
116 get { return value; }
120 get { return value.Year; }
123 #endregion // Properties
128 public int CompareTo (object obj)
130 throw new NotImplementedException ();
134 public override bool Equals (object value)
136 throw new NotImplementedException ();
139 public static OracleBoolean Equals (OracleDateTime x, OracleDateTime y)
141 if (x.IsNull || y.IsNull)
142 return OracleBoolean.Null;
143 return new OracleBoolean (x.Value == y.Value);
147 public override int GetHashCode ()
149 throw new NotImplementedException ();
152 public static OracleBoolean GreaterThan (OracleDateTime x, OracleDateTime y)
154 if (x.IsNull || y.IsNull)
155 return OracleBoolean.Null;
156 return new OracleBoolean (x.Value > y.Value);
159 public static OracleBoolean GreaterThanOrEqual (OracleDateTime x, OracleDateTime y)
161 if (x.IsNull || y.IsNull)
162 return OracleBoolean.Null;
163 return new OracleBoolean (x.Value >= y.Value);
166 public static OracleBoolean LessThan (OracleDateTime x, OracleDateTime y)
168 if (x.IsNull || y.IsNull)
169 return OracleBoolean.Null;
170 return new OracleBoolean (x.Value < y.Value);
173 public static OracleBoolean LessThanOrEqual (OracleDateTime x, OracleDateTime y)
175 if (x.IsNull || y.IsNull)
176 return OracleBoolean.Null;
177 return new OracleBoolean (x.Value <= y.Value);
180 public static OracleBoolean NotEquals (OracleDateTime x, OracleDateTime y)
182 if (x.IsNull || y.IsNull)
183 return OracleBoolean.Null;
184 return new OracleBoolean (x.Value != y.Value);
187 public static OracleDateTime Parse (string s)
189 return new OracleDateTime (DateTime.Parse (s));
192 public override string ToString ()
196 return Value.ToString ();
199 #endregion // Methods
201 #region Operators and Type Conversions
203 public static OracleBoolean operator == (OracleDateTime x, OracleDateTime y)
205 return Equals (x, y);
208 public static OracleBoolean operator > (OracleDateTime x, OracleDateTime y)
210 return GreaterThan (x, y);
213 public static OracleBoolean operator >= (OracleDateTime x, OracleDateTime y)
215 return GreaterThanOrEqual (x, y);
218 public static OracleBoolean operator != (OracleDateTime x, OracleDateTime y)
220 return NotEquals (x, y);
223 public static OracleBoolean operator < (OracleDateTime x, OracleDateTime y)
225 return LessThan (x, y);
228 public static OracleBoolean operator <= (OracleDateTime x, OracleDateTime y)
230 return LessThanOrEqual (x, y);
233 public static explicit operator DateTime (OracleDateTime x)
238 public static explicit operator OracleDateTime (DateTime x)
240 return new OracleDateTime (x);
243 #endregion // Operators and Type Conversions