22 namespace Deveel.Data.Types {
25 : base(
"DATE", typeCode) {
26 AssertDateType(typeCode);
29 public static readonly
string[] DateFormatSql = {
34 public static readonly
string[] TimeFormatSql = {
45 public static readonly
string[] TsFormatSql = {
46 "yyyy-MM-dd HH:mm:ss.fff",
47 "yyyy-MM-dd HH:mm:ss.fff z",
48 "yyyy-MM-dd HH:mm:ss.fff zz",
49 "yyyy-MM-dd HH:mm:ss.fff zzz",
50 "yyyy-MM-dd HH:mm:ss",
51 "yyyy-MM-dd HH:mm:ss z",
52 "yyyy-MM-dd HH:mm:ss zz",
53 "yyyy-MM-dd HH:mm:ss zzz",
55 "yyyy-MM-ddTHH:mm:ss.fff",
56 "yyyy-MM-ddTHH:mm:ss.fff z",
57 "yyyy-MM-ddTHH:mm:ss.fff zz",
58 "yyyy-MM-ddTHH:mm:ss.fff zzz",
59 "yyyy-MM-ddTHH:mm:ss",
60 "yyyy-MM-ddTHH:mm:ss z",
61 "yyyy-MM-ddTHH:mm:ss zz",
62 "yyyy-MM-ddTHH:mm:ss zzz",
67 if (!IsDateType(sqlType))
68 throw new ArgumentException(
String.Format(
"The SQL type {0} is not a valid DATE", sqlType),
"sqlType");
71 public override bool IsStorable {
84 return typeof (DateTimeOffset);
87 public override bool Equals(
object obj) {
96 return TypeCode.GetHashCode();
130 if (destType == null)
131 throw new ArgumentNullException(
"destType");
141 casted = ToString(date);
144 casted = ToDate(date);
147 casted = ToTime(date);
155 throw new InvalidCastException(
String.Format(
"Cannot cast type '{0}' to '{1}'.",
156 sqlType.ToString().ToUpperInvariant(), TypeCode.ToString().ToUpperInvariant()));
163 var writer =
new BinaryWriter(stream);
166 writer.Write((byte) 0);
171 writer.Write((byte)0);
173 var bytes = date.ToByteArray(
true);
175 writer.Write((byte)1);
176 writer.Write(bytes.Length);
187 throw new ArgumentException(
String.Format(
"Cannot determine the size of an object of type '{0}'", obj.GetType()));
197 var reader =
new BinaryReader(stream);
199 var type = reader.ReadByte();
203 var length = reader.ReadInt32();
204 var bytes = reader.ReadBytes(length);
override bool CanCastTo(SqlType destType)
Verifies if this type can cast any value to the given SqlType.
SqlDayToSecond Offset
Gets the offset between the date-time instance and the UTC time.
override Type GetRuntimeType()
A long string in the system.
override int GetHashCode()
override bool IsCacheable(ISqlObject value)
ISqlObject Value
Gets the underlined value that is handled.
SqlTypeCode TypeCode
Gets the kind of SQL type this data-type handles.
override void SerializeObject(Stream stream, ISqlObject obj)
override Type GetObjectType()
SqlString ToString(SqlDateTime dateTime)
bool IsNull
Gets a boolean value indicating if the object is NULL.
static SqlDateTime ToDate(SqlDateTime dateTime)
static bool IsDateType(SqlTypeCode sqlType)
static SqlDateTime ToTime(SqlDateTime dateTime)
Defines the contract for a valid SQL Object
DateType(SqlTypeCode typeCode)
override ISqlObject DeserializeObject(Stream stream)
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
override bool Equals(object obj)
static readonly SqlDateTime Null
Defines the properties of a specific SQL Type and handles the values compatible.
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
override DataObject CastTo(DataObject value, SqlType destType)
Converts the given object value to a SqlType specified.
override bool IsComparable(SqlType type)
Verifies if a given SqlType is comparable to this data-type.
override int ColumnSizeOf(ISqlObject obj)
SqlString ToTimeStampString()
static void AssertDateType(SqlTypeCode sqlType)