Files
MycLib/Src/Data/Myc.Data.Types.Timestamp.pas
T
Michael Schimmel 42110e8471 Data Types
2025-08-25 15:31:15 +02:00

81 lines
1.8 KiB
ObjectPascal

unit Myc.Data.Types.Timestamp;
interface
uses
System.SysUtils,
Myc.Data.Types;
type
TDataTimestampType = class(TInterfacedObject, IDataType, IDataTimestampType)
strict private
class var
FSingleton: IDataTimestampType;
class constructor CreateClass;
public
function GetName: String;
function GetKind: TDataKind;
function CreateValue(const AValue: TDateTime): IDataTimestampValue;
class property Singleton: IDataTimestampType read FSingleton;
end;
implementation
type
TDataTimestampValue = class(TInterfacedObject, IDataValue, IDataTimestampValue)
private
FValue: TDateTime;
function GetDataType: IDataType;
function GetAsString: string;
function GetValue: TDateTime;
public
constructor Create(const AValue: TDateTime);
end;
{ TDataTimestampType }
class constructor TDataTimestampType.CreateClass;
begin
FSingleton := TDataTimestampType.Create;
end;
function TDataTimestampType.CreateValue(const AValue: TDateTime): IDataTimestampValue;
begin
Result := TDataTimestampValue.Create(AValue);
end;
function TDataTimestampType.GetName: String;
begin
Result := 'Timestamp';
end;
function TDataTimestampType.GetKind: TDataKind;
begin
Result := dkTimestamp;
end;
{ TDataTimestampValue }
constructor TDataTimestampValue.Create(const AValue: TDateTime);
begin
inherited Create;
FValue := AValue;
end;
function TDataTimestampValue.GetDataType: IDataType;
begin
Result := TDataTimestampType.Singleton;
end;
function TDataTimestampValue.GetAsString: string;
begin
Result := DateTimeToStr(FValue);
end;
function TDataTimestampValue.GetValue: TDateTime;
begin
Result := FValue;
end;
end.