DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | Private Member Functions | Private Attributes | List of all members
Deveel.Data.Sql.Objects.SqlDateTime Struct Reference
Inheritance diagram for Deveel.Data.Sql.Objects.SqlDateTime:
Deveel.Data.Sql.Objects.ISqlObject

Public Member Functions

 SqlDateTime (int year, int month, int day)
 
 SqlDateTime (int year, int month, int day, int hour, int minute, int second, int millisecond)
 
 SqlDateTime (int year, int month, int day, int hour, int minute, int second, int millisecond, SqlDayToSecond offset)
 
 SqlDateTime (long ticks)
 
 SqlDateTime (long ticks, SqlDayToSecond offset)
 
 SqlDateTime (byte[] bytes)
 
int IComparable. CompareTo (object obj)
 
int IComparable< ISqlObject >. CompareTo (ISqlObject other)
 
bool ISqlObject. IsComparableTo (ISqlObject other)
 Checks if the current object is comparable with the given one. More...
 
TypeCode IConvertible. GetTypeCode ()
 
bool IConvertible. ToBoolean (IFormatProvider provider)
 
char IConvertible. ToChar (IFormatProvider provider)
 
sbyte IConvertible. ToSByte (IFormatProvider provider)
 
byte IConvertible. ToByte (IFormatProvider provider)
 
short IConvertible. ToInt16 (IFormatProvider provider)
 
ushort IConvertible. ToUInt16 (IFormatProvider provider)
 
int IConvertible. ToInt32 (IFormatProvider provider)
 
uint IConvertible. ToUInt32 (IFormatProvider provider)
 
long IConvertible. ToInt64 (IFormatProvider provider)
 
ulong IConvertible. ToUInt64 (IFormatProvider provider)
 
float IConvertible. ToSingle (IFormatProvider provider)
 
double IConvertible. ToDouble (IFormatProvider provider)
 
decimal IConvertible. ToDecimal (IFormatProvider provider)
 
DateTime IConvertible. ToDateTime (IFormatProvider provider)
 
string IConvertible. ToString (IFormatProvider provider)
 
object IConvertible. ToType (Type conversionType, IFormatProvider provider)
 
bool Equals (SqlDateTime other)
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
int CompareTo (SqlDateTime other)
 
long ToInt64 ()
 
byte[] ToByteArray ()
 
byte[] ToByteArray (bool timeZone)
 
SqlDateTime Add (SqlDayToSecond interval)
 Adds the given interval of time to this date-time. More...
 
SqlDateTime Subtract (SqlDayToSecond interval)
 Subtracts a given interval of time from this date. More...
 
SqlDateTime Add (SqlYearToMonth interval)
 Adds the given months to this date. More...
 
SqlDateTime Subtract (SqlYearToMonth interval)
 
SqlDateTime ToUtc ()
 
SqlString ToDateString ()
 
SqlString ToTimeString ()
 
SqlString ToTimeStampString ()
 
override string ToString ()
 
DateTime ToDateTime ()
 

Static Public Member Functions

static bool operator== (SqlDateTime a, SqlDateTime b)
 
static bool operator!= (SqlDateTime a, SqlDateTime b)
 
static bool operator> (SqlDateTime a, SqlDateTime b)
 
static bool operator< (SqlDateTime a, SqlDateTime b)
 
static bool operator>= (SqlDateTime a, SqlDateTime b)
 
static bool operator<= (SqlDateTime a, SqlDateTime b)
 
static SqlDateTime operator+ (SqlDateTime a, SqlDayToSecond b)
 
static SqlDateTime operator- (SqlDateTime a, SqlDayToSecond b)
 
static SqlDateTime operator+ (SqlDateTime a, SqlYearToMonth b)
 
static SqlDateTime operator- (SqlDateTime a, SqlYearToMonth b)
 
static SqlDateTime Parse (string s)
 
static bool TryParse (string s, out SqlDateTime value)
 
static bool TryParseDate (string s, out SqlDateTime value)
 
static bool TryParseTime (string s, out SqlDateTime value)
 
static bool TryParseTimeStamp (string s, out SqlDateTime value)
 
static implicit operator SqlDateTime (DateTimeOffset?a)
 
static implicit operator SqlDateTime (DateTimeOffset a)
 
static implicit operator DateTimeOffset? (SqlDateTime a)
 
static implicit operator DateTimeOffset (SqlDateTime a)
 

Public Attributes

const string TimeStringFormat = "HH:mm:ss.fff zzz"
 
const string TimeStampStringFormat = "yyyy-MM-ddTHH:mm:ss.fff zzz"
 
const string DateStringFormat = "yyyy-MM-dd"
 

Static Public Attributes

static readonly SqlDateTime Null = new SqlDateTime(true)
 
static readonly string[] SqlDateFormats
 
static readonly string[] SqlTimeStampFormats
 
static readonly string[] SqlTimeFormats
 
static readonly SqlDateTime MaxDate = new SqlDateTime(9999, 12, 31, 23, 59, 59, 999)
 
static readonly SqlDateTime MinDate = new SqlDateTime(1, 1, 1, 0, 0, 0, 0)
 

Properties

bool IsNull [get]
 
int Year [get]
 
int Month [get]
 
int Day [get]
 
int Hour [get]
 
int Minute [get]
 
int Second [get]
 
int Millisecond [get]
 
SqlDayToSecond Offset [get]
 Gets the offset between the date-time instance and the UTC time. More...
 
static SqlDateTime Now [get]
 
- Properties inherited from Deveel.Data.Sql.Objects.ISqlObject
bool IsNull [get]
 Gets a boolean value indicating if the object is NULL. More...
 

Private Member Functions

 SqlDateTime (bool isNull)
 
void AssertNotNull ()
 

Private Attributes

readonly DateTimeOffset value
 
const int DateSize = 7
 
const int TimeStampSize = 11
 
const int FullTimeStampSize = 13
 

Detailed Description

Definition at line 21 of file SqlDateTime.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Objects.SqlDateTime.SqlDateTime ( int  year,
int  month,
int  day 
)
inline

Definition at line 73 of file SqlDateTime.cs.

74  : this(year, month, day, 0, 0, 0, 0, SqlDayToSecond.Zero) {
75  }
Deveel.Data.Sql.Objects.SqlDateTime.SqlDateTime ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
int  millisecond 
)
inline

Definition at line 77 of file SqlDateTime.cs.

78  : this(year, month, day, hour, minute, second, millisecond, SqlDayToSecond.Zero) {
79  }
Deveel.Data.Sql.Objects.SqlDateTime.SqlDateTime ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
int  millisecond,
SqlDayToSecond  offset 
)
inline

Definition at line 81 of file SqlDateTime.cs.

82  : this() {
83  if (year <= 0 || year > 9999)
84  throw new ArgumentOutOfRangeException("year");
85  if (month <= 0 || month > 12)
86  throw new ArgumentOutOfRangeException("month");
87  if (day <= 0 || day > 31)
88  throw new ArgumentOutOfRangeException("day");
89 
90  if (hour < 0 || hour > 23)
91  throw new ArgumentOutOfRangeException("hour");
92  if (minute < 0 || minute > 59)
93  throw new ArgumentOutOfRangeException("minute");
94  if (second < 0 || second > 59)
95  throw new ArgumentOutOfRangeException("second");
96  if (millisecond < 0 || millisecond > 999)
97  throw new ArgumentOutOfRangeException("millisecond");
98 
99  var tsOffset = new TimeSpan(0, offset.Hours, offset.Minutes, 0, 0);
100  value = new DateTimeOffset(year, month, day, hour, minute, second, millisecond, tsOffset);
101  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
Deveel.Data.Sql.Objects.SqlDateTime.SqlDateTime ( long  ticks)
inline

Definition at line 103 of file SqlDateTime.cs.

104  : this(ticks, SqlDayToSecond.Zero) {
105  }
Deveel.Data.Sql.Objects.SqlDateTime.SqlDateTime ( long  ticks,
SqlDayToSecond  offset 
)
inline

Definition at line 107 of file SqlDateTime.cs.

108  : this() {
109  var tsOffset = new TimeSpan(0, offset.Hours, offset.Minutes, 0);
110  value = new DateTimeOffset(ticks, tsOffset);
111  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
Deveel.Data.Sql.Objects.SqlDateTime.SqlDateTime ( bool  isNull)
inlineprivate

Definition at line 113 of file SqlDateTime.cs.

114  : this() {
115  if (isNull)
116  value = null;
117  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
Deveel.Data.Sql.Objects.SqlDateTime.SqlDateTime ( byte[]  bytes)
inline

Definition at line 119 of file SqlDateTime.cs.

120  : this() {
121  var year = ((bytes[0] - 100)*100) + (bytes[1] - 100);
122  var month = (int) bytes[2];
123  var day = (int) bytes[3];
124  var hour = (int) bytes[4] - 1;
125  var minute = (int)bytes[5] - 1;
126  var second = (int)bytes[6] - 1;
127  int millis;
128  int tzh = 0, tzm = 0;
129 
130  if (bytes.Length == DateSize) {
131  millis = 0;
132  } else {
133  millis = bytes[7] << 24 | bytes[8] << 16 | bytes[9] << 8 | bytes[10];
134  if (bytes.Length == TimeStampSize) {
135  tzh = tzm = 0;
136  } else {
137  tzh = bytes[11] - 20;
138  tzm = bytes[12] - 60;
139  }
140  }
141 
142  value = new DateTimeOffset(year, month, day, hour, minute, second, millis, new TimeSpan(0, tzh, tzm, 0, 0));
143  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22

Member Function Documentation

SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.Add ( SqlDayToSecond  interval)
inline

Adds the given interval of time to this date-time.

Parameters
intervalThe interval of time to add.

This method will return Null if either the given interval is SqlDayToSecond.Null or if this instance is equivalent to NULL.

Returns
Returns an instance of SqlDateTime that is the result of the addition to this date of the given interval of time.

Definition at line 390 of file SqlDateTime.cs.

390  {
391  if (IsNull)
392  return Null;
393  if (interval.IsNull)
394  return this;
395 
396  var result = value.Value.AddMilliseconds(interval.TotalMilliseconds);
397  return new SqlDateTime(result.Ticks);
398  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
static readonly SqlDateTime Null
Definition: SqlDateTime.cs:24
SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.Add ( SqlYearToMonth  interval)
inline

Adds the given months to this date.

Parameters
intervalThe month-base interval of time to add.
Returns
See also
SqlYearToMonth

Definition at line 425 of file SqlDateTime.cs.

425  {
426  if (IsNull)
427  return Null;
428  if (interval.IsNull)
429  return this;
430 
431  var result = value.Value.AddMonths(interval.TotalMonths);
432  return new SqlDateTime(result.Ticks);
433  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
static readonly SqlDateTime Null
Definition: SqlDateTime.cs:24
void Deveel.Data.Sql.Objects.SqlDateTime.AssertNotNull ( )
inlineprivate

Definition at line 157 of file SqlDateTime.cs.

157  {
158  if (value == null)
159  throw new InvalidOperationException();
160  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
int IComparable. Deveel.Data.Sql.Objects.SqlDateTime.CompareTo ( object  obj)
inline

Definition at line 145 of file SqlDateTime.cs.

145  {
146  return CompareTo((SqlDateTime) obj);
147  }
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
int IComparable. CompareTo(object obj)
Definition: SqlDateTime.cs:145
int IComparable<ISqlObject>. Deveel.Data.Sql.Objects.SqlDateTime.CompareTo ( ISqlObject  other)
inline

Definition at line 149 of file SqlDateTime.cs.

149  {
150  return CompareTo((SqlDateTime) other);
151  }
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
int IComparable. CompareTo(object obj)
Definition: SqlDateTime.cs:145
int Deveel.Data.Sql.Objects.SqlDateTime.CompareTo ( SqlDateTime  other)
inline

Definition at line 332 of file SqlDateTime.cs.

332  {
333  if (!value.HasValue && !other.value.HasValue)
334  return 0;
335  if (!value.HasValue)
336  return 1;
337  if (!other.value.HasValue)
338  return -1;
339 
340  return value.Value.CompareTo(other.value.Value);
341  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
bool Deveel.Data.Sql.Objects.SqlDateTime.Equals ( SqlDateTime  other)
inline

Definition at line 317 of file SqlDateTime.cs.

317  {
318  if (IsNull && other.IsNull)
319  return true;
320 
321  return value.Equals(other.value);
322  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
override bool Deveel.Data.Sql.Objects.SqlDateTime.Equals ( object  obj)
inline

Definition at line 324 of file SqlDateTime.cs.

324  {
325  return Equals((SqlDateTime) obj);
326  }
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
bool Equals(SqlDateTime other)
Definition: SqlDateTime.cs:317
override int Deveel.Data.Sql.Objects.SqlDateTime.GetHashCode ( )
inline

Definition at line 328 of file SqlDateTime.cs.

328  {
329  return value == null ? 0 : value.GetHashCode();
330  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
TypeCode IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.GetTypeCode ( )
inline

Definition at line 233 of file SqlDateTime.cs.

233  {
234  return TypeCode.DateTime;
235  }
bool ISqlObject. Deveel.Data.Sql.Objects.SqlDateTime.IsComparableTo ( ISqlObject  other)
inline

Checks if the current object is comparable with the given one.

Parameters
otherThe other ISqlObject to compare.
Returns
Returns true if the current object is comparable with the given one, false otherwise.

Implements Deveel.Data.Sql.Objects.ISqlObject.

Definition at line 229 of file SqlDateTime.cs.

229  {
230  return other is SqlDateTime;
231  }
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
static implicit Deveel.Data.Sql.Objects.SqlDateTime.operator DateTimeOffset ( SqlDateTime  a)
inlinestatic

Definition at line 572 of file SqlDateTime.cs.

572  {
573  if (a == null || a.IsNull)
574  throw new NullReferenceException();
575 
576  var offset = new TimeSpan(a.Offset.Hours, a.Offset.Minutes, a.Offset.Seconds);
577  return new DateTimeOffset(a.Year, a.Month, a.Day, a.Hour, a.Minute, a.Second, a.Millisecond, offset);
578  }
static implicit Deveel.Data.Sql.Objects.SqlDateTime.operator DateTimeOffset? ( SqlDateTime  a)
inlinestatic

Definition at line 564 of file SqlDateTime.cs.

564  {
565  if (a == null || a.IsNull)
566  return null;
567 
568  var offset = new TimeSpan(a.Offset.Hours, a.Offset.Minutes, a.Offset.Seconds);
569  return new DateTimeOffset(a.Year, a.Month, a.Day, a.Hour, a.Minute, a.Second, a.Millisecond, offset);
570  }
static implicit Deveel.Data.Sql.Objects.SqlDateTime.operator SqlDateTime ( DateTimeOffset?  a)
inlinestatic

Definition at line 551 of file SqlDateTime.cs.

551  {
552  if (a == null)
553  return Null;
554 
555  return a.Value;
556  }
static readonly SqlDateTime Null
Definition: SqlDateTime.cs:24
static implicit Deveel.Data.Sql.Objects.SqlDateTime.operator SqlDateTime ( DateTimeOffset  a)
inlinestatic

Definition at line 558 of file SqlDateTime.cs.

558  {
559  var date = a;
560  var offset = new SqlDayToSecond(date.Offset.Days, date.Offset.Hours, date.Offset.Minutes, date.Offset.Seconds);
561  return new SqlDateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Millisecond, offset);
562  }
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
static bool Deveel.Data.Sql.Objects.SqlDateTime.operator!= ( SqlDateTime  a,
SqlDateTime  b 
)
inlinestatic

Definition at line 449 of file SqlDateTime.cs.

449  {
450  return !(a == b);
451  }
static SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.operator+ ( SqlDateTime  a,
SqlDayToSecond  b 
)
inlinestatic

Definition at line 471 of file SqlDateTime.cs.

471  {
472  return a.Add(b);
473  }
static SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.operator+ ( SqlDateTime  a,
SqlYearToMonth  b 
)
inlinestatic

Definition at line 479 of file SqlDateTime.cs.

479  {
480  return a.Add(b);
481  }
static SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.operator- ( SqlDateTime  a,
SqlDayToSecond  b 
)
inlinestatic

Definition at line 475 of file SqlDateTime.cs.

475  {
476  return a.Subtract(b);
477  }
static SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.operator- ( SqlDateTime  a,
SqlYearToMonth  b 
)
inlinestatic

Definition at line 483 of file SqlDateTime.cs.

483  {
484  return a.Subtract(b);
485  }
static bool Deveel.Data.Sql.Objects.SqlDateTime.operator< ( SqlDateTime  a,
SqlDateTime  b 
)
inlinestatic

Definition at line 457 of file SqlDateTime.cs.

457  {
458  return a.CompareTo(b) < 0;
459  }
static bool Deveel.Data.Sql.Objects.SqlDateTime.operator<= ( SqlDateTime  a,
SqlDateTime  b 
)
inlinestatic

Definition at line 466 of file SqlDateTime.cs.

466  {
467  var i = a.CompareTo(b);
468  return i == 0 || i < 0;
469  }
static bool Deveel.Data.Sql.Objects.SqlDateTime.operator== ( SqlDateTime  a,
SqlDateTime  b 
)
inlinestatic

Definition at line 445 of file SqlDateTime.cs.

445  {
446  return a.Equals(b);
447  }
static bool Deveel.Data.Sql.Objects.SqlDateTime.operator> ( SqlDateTime  a,
SqlDateTime  b 
)
inlinestatic

Definition at line 453 of file SqlDateTime.cs.

453  {
454  return a.CompareTo(b) > 0;
455  }
static bool Deveel.Data.Sql.Objects.SqlDateTime.operator>= ( SqlDateTime  a,
SqlDateTime  b 
)
inlinestatic

Definition at line 461 of file SqlDateTime.cs.

461  {
462  var i = a.CompareTo(b);
463  return i == 0 || i > 0;
464  }
static SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.Parse ( string  s)
inlinestatic

Definition at line 487 of file SqlDateTime.cs.

487  {
488  SqlDateTime date;
489  if (!TryParse(s, out date))
490  throw new FormatException(String.Format("Cannot convert string {0} to a valid SQL DATE", s));
491 
492  return date;
493  }
A long string in the system.
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
static bool TryParse(string s, out SqlDateTime value)
Definition: SqlDateTime.cs:495
SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.Subtract ( SqlDayToSecond  interval)
inline

Subtracts a given interval of time from this date.

Parameters
intervalThe interval to subtract from this date.
Returns
Returns an instance of SqlDateTime that is the result of the subtraction of the given interval of time from this date value.
See also
SqlDayToSecond

Definition at line 409 of file SqlDateTime.cs.

409  {
410  if (IsNull)
411  return Null;
412  if (interval.IsNull)
413  return this;
414 
415  var result = value.Value.AddMilliseconds(-(interval.TotalMilliseconds));
416  return new SqlDateTime(result.Ticks);
417  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
static readonly SqlDateTime Null
Definition: SqlDateTime.cs:24
SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.Subtract ( SqlYearToMonth  interval)
inline

Definition at line 435 of file SqlDateTime.cs.

435  {
436  if (IsNull)
437  return Null;
438  if (interval.IsNull)
439  return this;
440 
441  var result = value.Value.AddMonths(-interval.TotalMonths);
442  return new SqlDateTime(result.Ticks);
443  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
static readonly SqlDateTime Null
Definition: SqlDateTime.cs:24
bool IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToBoolean ( IFormatProvider  provider)
inline

Definition at line 237 of file SqlDateTime.cs.

237  {
238  throw new InvalidCastException();
239  }
byte IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToByte ( IFormatProvider  provider)
inline

Definition at line 249 of file SqlDateTime.cs.

249  {
250  throw new InvalidCastException();
251  }
byte [] Deveel.Data.Sql.Objects.SqlDateTime.ToByteArray ( )
inline

Definition at line 348 of file SqlDateTime.cs.

348  {
349  return ToByteArray(false);
350  }
byte [] Deveel.Data.Sql.Objects.SqlDateTime.ToByteArray ( bool  timeZone)
inline

Definition at line 352 of file SqlDateTime.cs.

352  {
353  var size = timeZone ? 13 : 11;
354  if (IsNull)
355  return new byte[size];
356 
357  var bytes = new byte[size];
358  bytes[0] = (byte)((Year / 100) + 100);
359  bytes[1] = (byte)((Year % 100) + 100);
360  bytes[2] = (byte)(Month);
361  bytes[3] = (byte)(Day);
362  bytes[4] = (byte)(Hour + 1);
363  bytes[5] = (byte)(Minute + 1);
364  bytes[6] = (byte)(Second + 1);
365  bytes[7] = (byte)((Millisecond >> 24));
366  bytes[8] = (byte)((Millisecond >> 16) & 0xff);
367  bytes[9] = (byte)((Millisecond >> 8) & 0xff);
368  bytes[10]= (byte)(Millisecond & 0xff);
369  if (timeZone) {
370  var tsOffset = Offset;
371  bytes[11] = (byte)(tsOffset.Hours + 20);
372  bytes[12] = (byte)(tsOffset.Minutes + 60);
373  }
374  return bytes;
375  }
SqlDayToSecond Offset
Gets the offset between the date-time instance and the UTC time.
Definition: SqlDateTime.cs:214
char IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToChar ( IFormatProvider  provider)
inline

Definition at line 241 of file SqlDateTime.cs.

241  {
242  throw new InvalidCastException();
243  }
SqlString Deveel.Data.Sql.Objects.SqlDateTime.ToDateString ( )
inline

Definition at line 589 of file SqlDateTime.cs.

589  {
590  if (value == null)
591  return SqlString.Null;
592 
593  var s = value.Value.ToString(DateStringFormat, CultureInfo.InvariantCulture);
594  return new SqlString(s);
595  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
Deveel.Data.Sql.Objects.SqlString SqlString
Definition: DataObject.cs:27
DateTime IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToDateTime ( IFormatProvider  provider)
inline

Definition at line 289 of file SqlDateTime.cs.

289  {
290  if (value == null)
291  throw new NullReferenceException();
292 
293  return value.Value.DateTime;
294  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
DateTime Deveel.Data.Sql.Objects.SqlDateTime.ToDateTime ( )
inline

Definition at line 620 of file SqlDateTime.cs.

620  {
621  if (value == null)
622  throw new InvalidCastException();
623 
624  return value.Value.DateTime;
625  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
decimal IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToDecimal ( IFormatProvider  provider)
inline

Definition at line 285 of file SqlDateTime.cs.

285  {
286  throw new NotImplementedException();
287  }
double IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToDouble ( IFormatProvider  provider)
inline

Definition at line 281 of file SqlDateTime.cs.

281  {
282  return ToInt64();
283  }
short IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToInt16 ( IFormatProvider  provider)
inline

Definition at line 253 of file SqlDateTime.cs.

253  {
254  throw new InvalidCastException();
255  }
int IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToInt32 ( IFormatProvider  provider)
inline

Definition at line 261 of file SqlDateTime.cs.

261  {
262  throw new InvalidCastException();
263  }
long IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToInt64 ( IFormatProvider  provider)
inline

Definition at line 269 of file SqlDateTime.cs.

269  {
270  return ToInt64();
271  }
long Deveel.Data.Sql.Objects.SqlDateTime.ToInt64 ( )
inline

Definition at line 343 of file SqlDateTime.cs.

343  {
344  AssertNotNull();
345  return value.Value.Ticks;
346  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
sbyte IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToSByte ( IFormatProvider  provider)
inline

Definition at line 245 of file SqlDateTime.cs.

245  {
246  throw new NotImplementedException();
247  }
float IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToSingle ( IFormatProvider  provider)
inline

Definition at line 277 of file SqlDateTime.cs.

277  {
278  return ToInt64();
279  }
string IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToString ( IFormatProvider  provider)
inline

Definition at line 296 of file SqlDateTime.cs.

296  {
297  return ToString();
298  }
override string Deveel.Data.Sql.Objects.SqlDateTime.ToString ( )
inline

Definition at line 613 of file SqlDateTime.cs.

613  {
614  if (value == null)
615  return "NULL";
616 
617  return ToTimeStampString().ToString();
618  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
string ToString(Encoding encoding)
Definition: SqlString.cs:182
SqlString Deveel.Data.Sql.Objects.SqlDateTime.ToTimeStampString ( )
inline

Definition at line 605 of file SqlDateTime.cs.

605  {
606  if (value == null)
607  return SqlString.Null;
608 
609  var s = value.Value.ToString(TimeStampStringFormat, CultureInfo.InvariantCulture);
610  return new SqlString(s);
611  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
Deveel.Data.Sql.Objects.SqlString SqlString
Definition: DataObject.cs:27
SqlString Deveel.Data.Sql.Objects.SqlDateTime.ToTimeString ( )
inline

Definition at line 597 of file SqlDateTime.cs.

597  {
598  if (value == null)
599  return SqlString.Null;
600 
601  var s = value.Value.ToString(TimeStringFormat, CultureInfo.InvariantCulture);
602  return new SqlString(s);
603  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
Deveel.Data.Sql.Objects.SqlString SqlString
Definition: DataObject.cs:27
object IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToType ( Type  conversionType,
IFormatProvider  provider 
)
inline

Definition at line 300 of file SqlDateTime.cs.

300  {
301  if (conversionType == typeof (long))
302  return ToInt64();
303  if (conversionType == typeof (float))
304  return (float) ToInt64();
305  if (conversionType == typeof (double))
306  return (double) ToInt64();
307 
308  if (conversionType == typeof (string))
309  return ToString();
310 
311  if (conversionType == typeof (byte[]))
312  return ToByteArray();
313 
314  throw new InvalidCastException();
315  }
ushort IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToUInt16 ( IFormatProvider  provider)
inline

Definition at line 257 of file SqlDateTime.cs.

257  {
258  throw new InvalidCastException();
259  }
uint IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToUInt32 ( IFormatProvider  provider)
inline

Definition at line 265 of file SqlDateTime.cs.

265  {
266  throw new InvalidCastException();
267  }
ulong IConvertible. Deveel.Data.Sql.Objects.SqlDateTime.ToUInt64 ( IFormatProvider  provider)
inline

Definition at line 273 of file SqlDateTime.cs.

273  {
274  return (ulong) ToInt64();
275  }
SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.ToUtc ( )
inline

Definition at line 580 of file SqlDateTime.cs.

580  {
581  if (value == null)
582  return Null;
583 
584  var utc = value.Value.ToUniversalTime();
585  var offset = new SqlDayToSecond(utc.Offset.Days, utc.Offset.Hours, utc.Offset.Minutes);
586  return new SqlDateTime(utc.Year, utc.Month, utc.Day, utc.Hour, utc.Minute, utc.Second, utc.Millisecond, offset);
587  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
static readonly SqlDateTime Null
Definition: SqlDateTime.cs:24
static bool Deveel.Data.Sql.Objects.SqlDateTime.TryParse ( string  s,
out SqlDateTime  value 
)
inlinestatic

Definition at line 495 of file SqlDateTime.cs.

495  {
496  // We delegate parsing DATE and TIME strings to the .NET DateTime object...
497  if (TryParseDate(s, out value))
498  return true;
499 
500  if (TryParseTime(s, out value))
501  return true;
502 
503  if (TryParseTimeStamp(s, out value))
504  return true;
505 
506  value = new SqlDateTime();
507  return false;
508  }
static bool TryParseTimeStamp(string s, out SqlDateTime value)
Definition: SqlDateTime.cs:537
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
static bool TryParseTime(string s, out SqlDateTime value)
Definition: SqlDateTime.cs:523
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
static bool TryParseDate(string s, out SqlDateTime value)
Definition: SqlDateTime.cs:510
static bool Deveel.Data.Sql.Objects.SqlDateTime.TryParseDate ( string  s,
out SqlDateTime  value 
)
inlinestatic

Definition at line 510 of file SqlDateTime.cs.

510  {
511  value = new SqlDateTime();
512 
513  // We delegate parsing DATE and TIME strings to the .NET DateTime object...
514  DateTimeOffset date;
515  if (DateTimeOffset.TryParseExact(s, SqlDateFormats, CultureInfo.InvariantCulture, DateTimeStyles.None, out date)) {
516  value = new SqlDateTime(date.Year, date.Month, date.Day, 0, 0, 0, 0, SqlDayToSecond.Zero);
517  return true;
518  }
519 
520  return false;
521  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
static readonly string[] SqlDateFormats
Definition: SqlDateTime.cs:30
static bool Deveel.Data.Sql.Objects.SqlDateTime.TryParseTime ( string  s,
out SqlDateTime  value 
)
inlinestatic

Definition at line 523 of file SqlDateTime.cs.

523  {
524  value = new SqlDateTime();
525 
526  // We delegate parsing DATE and TIME strings to the .NET DateTime object...
527  DateTimeOffset date;
528  if (DateTimeOffset.TryParseExact(s, SqlTimeFormats, CultureInfo.InvariantCulture, DateTimeStyles.None, out date)) {
529  var offset = new SqlDayToSecond(date.Offset.Hours, date.Offset.Minutes,0);
530  value = new SqlDateTime(1, 1, 1, date.Hour, date.Minute, date.Second, date.Millisecond, offset);
531  return true;
532  }
533 
534  return false;
535  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
static readonly string[] SqlTimeFormats
Definition: SqlDateTime.cs:55
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73
static bool Deveel.Data.Sql.Objects.SqlDateTime.TryParseTimeStamp ( string  s,
out SqlDateTime  value 
)
inlinestatic

Definition at line 537 of file SqlDateTime.cs.

537  {
538  value = new SqlDateTime();
539 
540  // We delegate parsing DATE and TIME strings to the .NET DateTime object...
541  DateTimeOffset date;
542  if (DateTimeOffset.TryParseExact(s, SqlTimeStampFormats, CultureInfo.InvariantCulture, DateTimeStyles.None, out date)) {
543  var offset = new SqlDayToSecond(date.Offset.Hours, date.Offset.Minutes, 0);
544  value = new SqlDateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Millisecond, offset);
545  return true;
546  }
547 
548  return false;
549  }
readonly DateTimeOffset value
Definition: SqlDateTime.cs:22
static readonly string[] SqlTimeStampFormats
Definition: SqlDateTime.cs:35
SqlDateTime(int year, int month, int day)
Definition: SqlDateTime.cs:73

Member Data Documentation

const int Deveel.Data.Sql.Objects.SqlDateTime.DateSize = 7
private

Definition at line 26 of file SqlDateTime.cs.

const string Deveel.Data.Sql.Objects.SqlDateTime.DateStringFormat = "yyyy-MM-dd"

Definition at line 68 of file SqlDateTime.cs.

const int Deveel.Data.Sql.Objects.SqlDateTime.FullTimeStampSize = 13
private

Definition at line 28 of file SqlDateTime.cs.

readonly SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.MaxDate = new SqlDateTime(9999, 12, 31, 23, 59, 59, 999)
static

Definition at line 70 of file SqlDateTime.cs.

readonly SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.MinDate = new SqlDateTime(1, 1, 1, 0, 0, 0, 0)
static

Definition at line 71 of file SqlDateTime.cs.

readonly SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.Null = new SqlDateTime(true)
static

Definition at line 24 of file SqlDateTime.cs.

readonly string [] Deveel.Data.Sql.Objects.SqlDateTime.SqlDateFormats
static
Initial value:
= new[] {
"yyyy-MM-dd",
"yyyy MM dd"
}

Definition at line 30 of file SqlDateTime.cs.

readonly string [] Deveel.Data.Sql.Objects.SqlDateTime.SqlTimeFormats
static
Initial value:
= new[] {
"HH:mm:ss.fff z",
"HH:mm:ss.fff zz",
"HH:mm:ss.fff zzz",
"HH:mm:ss.fff",
"HH:mm:ss z",
"HH:mm:ss zz",
"HH:mm:ss zzz",
"HH:mm:ss"
}

Definition at line 55 of file SqlDateTime.cs.

readonly string [] Deveel.Data.Sql.Objects.SqlDateTime.SqlTimeStampFormats
static
Initial value:
= new[] {
"yyyy-MM-dd HH:mm:ss.fff",
"yyyy-MM-dd HH:mm:ss.fff z",
"yyyy-MM-dd HH:mm:ss.fff zz",
"yyyy-MM-dd HH:mm:ss.fff zzz",
"yyyy-MM-dd HH:mm:ss",
"yyyy-MM-dd HH:mm:ss z",
"yyyy-MM-dd HH:mm:ss zz",
"yyyy-MM-dd HH:mm:ss zzz",
"yyyy-MM-ddTHH:mm:ss.fff",
"yyyy-MM-ddTHH:mm:ss.fff z",
"yyyy-MM-ddTHH:mm:ss.fff zz",
"yyyy-MM-ddTHH:mm:ss.fff zzz",
"yyyy-MM-ddTHH:mm:ss",
"yyyy-MM-ddTHH:mm:ss z",
"yyyy-MM-ddTHH:mm:ss zz",
"yyyy-MM-ddTHH:mm:ss zzz",
}

Definition at line 35 of file SqlDateTime.cs.

const int Deveel.Data.Sql.Objects.SqlDateTime.TimeStampSize = 11
private

Definition at line 27 of file SqlDateTime.cs.

const string Deveel.Data.Sql.Objects.SqlDateTime.TimeStampStringFormat = "yyyy-MM-ddTHH:mm:ss.fff zzz"

Definition at line 67 of file SqlDateTime.cs.

const string Deveel.Data.Sql.Objects.SqlDateTime.TimeStringFormat = "HH:mm:ss.fff zzz"

Definition at line 66 of file SqlDateTime.cs.

readonly DateTimeOffset Deveel.Data.Sql.Objects.SqlDateTime.value
private

Definition at line 22 of file SqlDateTime.cs.

Property Documentation

int Deveel.Data.Sql.Objects.SqlDateTime.Day
get

Definition at line 176 of file SqlDateTime.cs.

int Deveel.Data.Sql.Objects.SqlDateTime.Hour
get

Definition at line 183 of file SqlDateTime.cs.

bool Deveel.Data.Sql.Objects.SqlDateTime.IsNull
get

Definition at line 153 of file SqlDateTime.cs.

int Deveel.Data.Sql.Objects.SqlDateTime.Millisecond
get

Definition at line 204 of file SqlDateTime.cs.

int Deveel.Data.Sql.Objects.SqlDateTime.Minute
get

Definition at line 190 of file SqlDateTime.cs.

int Deveel.Data.Sql.Objects.SqlDateTime.Month
get

Definition at line 169 of file SqlDateTime.cs.

SqlDateTime Deveel.Data.Sql.Objects.SqlDateTime.Now
staticget

Definition at line 221 of file SqlDateTime.cs.

SqlDayToSecond Deveel.Data.Sql.Objects.SqlDateTime.Offset
get

Gets the offset between the date-time instance and the UTC time.

Definition at line 214 of file SqlDateTime.cs.

int Deveel.Data.Sql.Objects.SqlDateTime.Second
get

Definition at line 197 of file SqlDateTime.cs.

int Deveel.Data.Sql.Objects.SqlDateTime.Year
get

Definition at line 162 of file SqlDateTime.cs.


The documentation for this struct was generated from the following file: