Data Types

This commit is contained in:
Michael Schimmel
2025-08-25 15:31:15 +02:00
parent c9e28a946d
commit 42110e8471
10 changed files with 980 additions and 193 deletions
+18 -17
View File
@@ -7,7 +7,7 @@ uses
Myc.Data.Types;
type
TImplDataTimestampType = class(TInterfacedObject, IDataType, IDataTimestampType)
TDataTimestampType = class(TInterfacedObject, IDataType, IDataTimestampType)
strict private
class var
FSingleton: IDataTimestampType;
@@ -19,7 +19,10 @@ type
class property Singleton: IDataTimestampType read FSingleton;
end;
TImplDataTimestampValue = class(TInterfacedObject, IDataValue, IDataTimestampValue)
implementation
type
TDataTimestampValue = class(TInterfacedObject, IDataValue, IDataTimestampValue)
private
FValue: TDateTime;
function GetDataType: IDataType;
@@ -29,49 +32,47 @@ type
constructor Create(const AValue: TDateTime);
end;
implementation
{ TDataTimestampType }
{ TImplDataTimestampType }
class constructor TImplDataTimestampType.CreateClass;
class constructor TDataTimestampType.CreateClass;
begin
FSingleton := TImplDataTimestampType.Create;
FSingleton := TDataTimestampType.Create;
end;
function TImplDataTimestampType.CreateValue(const AValue: TDateTime): IDataTimestampValue;
function TDataTimestampType.CreateValue(const AValue: TDateTime): IDataTimestampValue;
begin
Result := TImplDataTimestampValue.Create(AValue);
Result := TDataTimestampValue.Create(AValue);
end;
function TImplDataTimestampType.GetName: String;
function TDataTimestampType.GetName: String;
begin
Result := 'Timestamp';
end;
function TImplDataTimestampType.GetKind: TDataKind;
function TDataTimestampType.GetKind: TDataKind;
begin
Result := dkTimestamp;
end;
{ TImplDataTimestampValue }
{ TDataTimestampValue }
constructor TImplDataTimestampValue.Create(const AValue: TDateTime);
constructor TDataTimestampValue.Create(const AValue: TDateTime);
begin
inherited Create;
FValue := AValue;
end;
function TImplDataTimestampValue.GetDataType: IDataType;
function TDataTimestampValue.GetDataType: IDataType;
begin
Result := TImplDataTimestampType.Singleton;
Result := TDataTimestampType.Singleton;
end;
function TImplDataTimestampValue.GetAsString: string;
function TDataTimestampValue.GetAsString: string;
begin
Result := DateTimeToStr(FValue);
end;
function TImplDataTimestampValue.GetValue: TDateTime;
function TDataTimestampValue.GetValue: TDateTime;
begin
Result := FValue;
end;