**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Data.OracleClient / System.Data.OracleClient / OracleTimeSpan.cs
blob4e2bbb30a30d07a68af721551406f04862987223
1 //
2 // OracleTimeSpan.cs
3 //
4 // Part of the Mono class libraries at
5 // mcs/class/System.Data.OracleClient/System.Data.OracleClient
6 //
7 // Assembly: System.Data.OracleClient.dll
8 // Namespace: System.Data.OracleClient
9 //
10 // Author: Tim Coleman <tim@timcoleman.com>
12 // Copyright (C) Tim Coleman, 2003
14 // Licensed under the MIT/X11 License.
17 using System;
18 using System.Data.SqlTypes;
20 namespace System.Data.OracleClient {
21 public struct OracleTimeSpan : IComparable, INullable
23 #region Fields
25 public static readonly OracleTimeSpan MaxValue = new OracleTimeSpan (TimeSpan.MaxValue);
26 public static readonly OracleTimeSpan MinValue = new OracleTimeSpan (TimeSpan.MinValue);
27 public static readonly OracleTimeSpan Null = new OracleTimeSpan ();
29 bool notNull;
30 TimeSpan value;
32 #endregion // Fields
34 #region Constructors
36 public OracleTimeSpan (long ticks)
37 : this (new TimeSpan (ticks))
41 public OracleTimeSpan (OracleTimeSpan from)
42 : this (from.Value)
46 public OracleTimeSpan (TimeSpan ts)
48 value = ts;
49 notNull = true;
52 public OracleTimeSpan (int hours, int minutes, int seconds)
53 : this (new TimeSpan (hours, minutes, seconds))
57 public OracleTimeSpan (int days, int hours, int minutes, int seconds)
58 : this (new TimeSpan (days, hours, minutes, seconds))
62 public OracleTimeSpan (int days, int hours, int minutes, int seconds, int milliseconds)
63 : this (new TimeSpan (days, hours, minutes, seconds, milliseconds))
67 #endregion // Constructors
69 #region Properties
71 public int Days {
72 get { return Value.Days; }
75 public int Hours {
76 get { return Value.Days; }
79 public bool IsNull {
80 get { return !notNull; }
83 public int Milliseconds {
84 get { return Value.Milliseconds; }
87 public int Minutes {
88 get { return Value.Minutes; }
91 public int Seconds {
92 get { return Value.Seconds; }
95 public TimeSpan Value {
96 get { return value; }
99 #endregion // Properties
101 #region Methods
103 [MonoTODO]
104 public int CompareTo (object obj)
106 throw new NotImplementedException ();
109 [MonoTODO]
110 public override bool Equals (object value)
112 throw new NotImplementedException ();
115 public static OracleBoolean Equals (OracleTimeSpan x, OracleTimeSpan y)
117 if (x.IsNull || y.IsNull)
118 return OracleBoolean.Null;
119 return new OracleBoolean (x.Value == y.Value);
122 [MonoTODO]
123 public override int GetHashCode ()
125 throw new NotImplementedException ();
128 public static OracleBoolean GreaterThan (OracleTimeSpan x, OracleTimeSpan y)
130 if (x.IsNull || y.IsNull)
131 return OracleBoolean.Null;
132 return (x.Value > y.Value);
135 public static OracleBoolean GreaterThanOrEqual (OracleTimeSpan x, OracleTimeSpan y)
137 if (x.IsNull || y.IsNull)
138 return OracleBoolean.Null;
139 return (x.Value >= y.Value);
142 public static OracleBoolean LessThan (OracleTimeSpan x, OracleTimeSpan y)
144 if (x.IsNull || y.IsNull)
145 return OracleBoolean.Null;
146 return (x.Value < y.Value);
149 public static OracleBoolean LessThanOrEqual (OracleTimeSpan x, OracleTimeSpan y)
151 if (x.IsNull || y.IsNull)
152 return OracleBoolean.Null;
153 return (x.Value <= y.Value);
156 public static OracleBoolean NotEquals (OracleTimeSpan x, OracleTimeSpan y)
158 if (x.IsNull || y.IsNull)
159 return OracleBoolean.Null;
160 return (x.Value != y.Value);
163 public static OracleTimeSpan Parse (string s)
165 return new OracleTimeSpan (TimeSpan.Parse (s));
168 public override string ToString ()
170 if (IsNull)
171 return "Null";
172 return value.ToString ();
175 #endregion // Methods
177 #region Operators and Type Conversions
179 public static OracleBoolean operator == (OracleTimeSpan x, OracleTimeSpan y)
181 return Equals (x, y);
184 public static OracleBoolean operator > (OracleTimeSpan x, OracleTimeSpan y)
186 return GreaterThan (x, y);
189 public static OracleBoolean operator >= (OracleTimeSpan x, OracleTimeSpan y)
191 return GreaterThanOrEqual (x, y);
194 public static OracleBoolean operator != (OracleTimeSpan x, OracleTimeSpan y)
196 return NotEquals (x, y);
199 public static OracleBoolean operator < (OracleTimeSpan x, OracleTimeSpan y)
201 return LessThan (x, y);
204 public static OracleBoolean operator <= (OracleTimeSpan x, OracleTimeSpan y)
206 return LessThan (x, y);
209 public static explicit operator TimeSpan (OracleTimeSpan x)
211 return x.Value;
214 public static explicit operator OracleTimeSpan (string s)
216 return Parse (s);
219 #endregion // Operators and Type Conversions