mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 07:45:54 +01:00
Improved CRUD sample
This commit is contained in:
parent
4a65b78fb5
commit
11c7b397d4
@ -23,9 +23,13 @@ type
|
||||
FPrice: Currency;
|
||||
FCode: string;
|
||||
FDescription: String;
|
||||
FUpdatedAt: TDateTime;
|
||||
FCreatedAt: TDateTime;
|
||||
procedure SetCode(const Value: string);
|
||||
procedure SetDescription(const Value: String);
|
||||
procedure SetPrice(const Value: Currency);
|
||||
procedure SetCreatedAt(const Value: TDateTime);
|
||||
procedure SetUpdatedAt(const Value: TDateTime);
|
||||
public
|
||||
procedure CheckInsert; override;
|
||||
procedure CheckUpdate; override;
|
||||
@ -36,6 +40,10 @@ type
|
||||
property Description: String read FDescription write SetDescription;
|
||||
[MVCColumn('PREZZO')]
|
||||
property Price: Currency read FPrice write SetPrice;
|
||||
[MVCColumn('CREATED_AT')]
|
||||
property CreatedAt: TDateTime read FCreatedAt write SetCreatedAt;
|
||||
[MVCColumn('UPDATED_AT')]
|
||||
property UpdatedAt: TDateTime read FUpdatedAt write SetUpdatedAt;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -94,6 +102,11 @@ begin
|
||||
FCode := Value;
|
||||
end;
|
||||
|
||||
procedure TArticle.SetCreatedAt(const Value: TDateTime);
|
||||
begin
|
||||
FCreatedAt := Value;
|
||||
end;
|
||||
|
||||
procedure TArticle.SetDescription(const Value: String);
|
||||
begin
|
||||
FDescription := Value;
|
||||
@ -104,4 +117,9 @@ begin
|
||||
FPrice := Value;
|
||||
end;
|
||||
|
||||
procedure TArticle.SetUpdatedAt(const Value: TDateTime);
|
||||
begin
|
||||
FUpdatedAt := Value;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -104,7 +104,7 @@ end;
|
||||
|
||||
function TArticlesService.GetMeta: TJSONObject;
|
||||
begin
|
||||
FDM.dsArticles.Open('SELECT ID, CODICE as CODE, DESCRIZIONE as DESCRIPTION, PREZZO as PRICE FROM ARTICOLI WHERE TRUE = FALSE');
|
||||
FDM.dsArticles.Open('SELECT ID, CODICE as CODE, DESCRIZIONE as DESCRIPTION, PREZZO as PRICE, CREATED_AT as CREATEDAT, UPDATED_AT as UPDATEDAT FROM ARTICOLI WHERE TRUE = FALSE');
|
||||
Result := FDM.dsArticles.MetadataAsJSONObject();
|
||||
end;
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
[FDConnectionDefs.ini]
|
||||
Encoding=UTF8
|
||||
|
||||
;this is the default connection used by DMSContainer - all the others connection will be ignored
|
||||
[articles_crud_db]
|
||||
DriverID=FB
|
||||
Pooling=True
|
||||
|
@ -135,6 +135,18 @@ object MainForm: TMainForm
|
||||
FieldName = 'price'
|
||||
Title.Caption = 'Price'
|
||||
Visible = True
|
||||
end
|
||||
item
|
||||
Expanded = False
|
||||
FieldName = 'createdat'
|
||||
ReadOnly = True
|
||||
Visible = True
|
||||
end
|
||||
item
|
||||
Expanded = False
|
||||
FieldName = 'updatedat'
|
||||
ReadOnly = True
|
||||
Visible = True
|
||||
end>
|
||||
end
|
||||
object dsArticles: TFDMemTable
|
||||
@ -167,6 +179,14 @@ object MainForm: TMainForm
|
||||
object dsArticlesprice: TCurrencyField
|
||||
FieldName = 'price'
|
||||
end
|
||||
object dsArticlescreatedat: TDateTimeField
|
||||
AutoGenerateValue = arDefault
|
||||
FieldName = 'createdat'
|
||||
end
|
||||
object dsArticlesupdatedat: TDateTimeField
|
||||
AutoGenerateValue = arDefault
|
||||
FieldName = 'updatedat'
|
||||
end
|
||||
end
|
||||
object dsrcArticles: TDataSource
|
||||
DataSet = dsArticles
|
||||
|
@ -28,6 +28,8 @@ type
|
||||
EditFilter: TEdit;
|
||||
Label1: TLabel;
|
||||
btnFilter: TButton;
|
||||
dsArticlescreatedat: TDateTimeField;
|
||||
dsArticlesupdatedat: TDateTimeField;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure dsArticlesBeforePost(DataSet: TDataSet);
|
||||
procedure dsArticlesBeforeDelete(DataSet: TDataSet);
|
||||
|
@ -1,6 +1,6 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{B180E3D7-5F42-49CE-84F1-042196300A37}</ProjectGuid>
|
||||
<ProjectGuid>{C3AD62C8-92C8-4742-A585-69B14E177684}</ProjectGuid>
|
||||
<ProjectVersion>19.1</ProjectVersion>
|
||||
<FrameworkType>VCL</FrameworkType>
|
||||
<MainSource>articles_crud_vcl_client.dpr</MainSource>
|
||||
|
@ -136,6 +136,22 @@ object MainForm: TMainForm
|
||||
FieldName = 'price'
|
||||
Title.Caption = 'Price'
|
||||
Visible = True
|
||||
end
|
||||
item
|
||||
Expanded = False
|
||||
FieldName = 'createdat'
|
||||
ReadOnly = True
|
||||
Title.Caption = 'Created At'
|
||||
Title.Color = clBtnShadow
|
||||
Visible = True
|
||||
end
|
||||
item
|
||||
Expanded = False
|
||||
FieldName = 'updatedat'
|
||||
ReadOnly = True
|
||||
Title.Caption = 'Updated At'
|
||||
Title.Color = clBtnShadow
|
||||
Visible = True
|
||||
end>
|
||||
end
|
||||
object dsArticles: TFDMemTable
|
||||
@ -163,6 +179,14 @@ object MainForm: TMainForm
|
||||
object dsArticlesprice: TCurrencyField
|
||||
FieldName = 'price'
|
||||
end
|
||||
object dsArticlescreated_at: TDateTimeField
|
||||
AutoGenerateValue = arDefault
|
||||
FieldName = 'createdat'
|
||||
end
|
||||
object dsArticlesupdated_at: TDateTimeField
|
||||
AutoGenerateValue = arDefault
|
||||
FieldName = 'updatedat'
|
||||
end
|
||||
end
|
||||
object dsrcArticles: TDataSource
|
||||
DataSet = dsArticles
|
||||
|
@ -28,6 +28,8 @@ type
|
||||
EditFilter: TEdit;
|
||||
Label1: TLabel;
|
||||
btnFilter: TButton;
|
||||
dsArticlescreated_at: TDateTimeField;
|
||||
dsArticlesupdated_at: TDateTimeField;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure dsArticlesBeforePost(DataSet: TDataSet);
|
||||
procedure dsArticlesBeforeDelete(DataSet: TDataSet);
|
||||
|
@ -2,8 +2,7 @@ program articles_crud_vcl_client_api_binder;
|
||||
|
||||
uses
|
||||
Vcl.Forms,
|
||||
MainFormU in 'MainFormU.pas' {MainForm},
|
||||
MVCFramework.Serializer.Defaults in '..\..\sources\MVCFramework.Serializer.Defaults.pas';
|
||||
MainFormU in 'MainFormU.pas' {MainForm};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{B180E3D7-5F42-49CE-84F1-042196300A37}</ProjectGuid>
|
||||
<ProjectVersion>18.8</ProjectVersion>
|
||||
<ProjectVersion>19.1</ProjectVersion>
|
||||
<FrameworkType>VCL</FrameworkType>
|
||||
<MainSource>articles_crud_vcl_client_api_binder.dpr</MainSource>
|
||||
<Base>True</Base>
|
||||
@ -100,7 +100,6 @@
|
||||
<Form>MainForm</Form>
|
||||
<FormType>dfm</FormType>
|
||||
</DCCReference>
|
||||
<DCCReference Include="..\..\sources\MVCFramework.Serializer.Defaults.pas"/>
|
||||
<BuildConfiguration Include="Release">
|
||||
<Key>Cfg_2</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
@ -527,6 +526,32 @@
|
||||
<Operation>0</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iOS_AppStore1024">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPad_AppIcon152">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPad_AppIcon167">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPad_Launch1024">
|
||||
<Platform Name="iOSDevice32">
|
||||
<Operation>1</Operation>
|
||||
@ -659,6 +684,16 @@
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPad_Launch2x">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPad_Launch768">
|
||||
<Platform Name="iOSDevice32">
|
||||
<Operation>1</Operation>
|
||||
@ -681,6 +716,66 @@
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPad_LaunchDark2x">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPad_Notification40">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPad_Setting58">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPad_SpotLight80">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_AppIcon120">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_AppIcon180">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_Launch1125">
|
||||
<Platform Name="iOSDevice32">
|
||||
<Operation>1</Operation>
|
||||
@ -780,6 +875,16 @@
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_Launch2x">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_Launch320">
|
||||
<Platform Name="iOSDevice32">
|
||||
<Operation>1</Operation>
|
||||
@ -791,6 +896,16 @@
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_Launch3x">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_Launch640">
|
||||
<Platform Name="iOSDevice32">
|
||||
<Operation>1</Operation>
|
||||
@ -835,6 +950,86 @@
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_LaunchDark2x">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_LaunchDark3x">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_Notification40">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_Notification60">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_Setting58">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_Setting87">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_Spotlight120">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="iPhone_Spotlight80">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="ProjectAndroidManifest">
|
||||
<Platform Name="Android">
|
||||
<Operation>1</Operation>
|
||||
@ -882,6 +1077,16 @@
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="ProjectiOSLaunchScreen">
|
||||
<Platform Name="iOSDevice64">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen</RemoteDir>
|
||||
<Operation>64</Operation>
|
||||
</Platform>
|
||||
<Platform Name="iOSSimulator">
|
||||
<RemoteDir>..\$(PROJECTNAME).launchscreen</RemoteDir>
|
||||
<Operation>64</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<DeployClass Name="ProjectiOSResource">
|
||||
<Platform Name="iOSDevice32">
|
||||
<Operation>1</Operation>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{B180E3D7-5F42-49CE-84F1-042196300A37}</ProjectGuid>
|
||||
<ProjectGuid>{24032D46-0747-4390-A3B3-70CF1A3EB327}</ProjectGuid>
|
||||
<ProjectVersion>19.1</ProjectVersion>
|
||||
<FrameworkType>VCL</FrameworkType>
|
||||
<MainSource>articles_crud_vcl_client_meta.dpr</MainSource>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1384,10 +1384,10 @@ begin
|
||||
TFieldType.ftDate:
|
||||
Field.AsDateTime := ISODateToDate(AJsonObject.S[lName]);
|
||||
|
||||
TFieldType.ftDateTime:
|
||||
TFieldType.ftDateTime, TFieldType.ftTimeStamp:
|
||||
Field.AsDateTime := ISOTimeStampToDateTime(AJsonObject.S[lName]);
|
||||
|
||||
TFieldType.ftTimeStamp, TFieldType.ftTime:
|
||||
TFieldType.ftTime:
|
||||
Field.AsDateTime := ISOTimeToTime(AJsonObject.S[lName]);
|
||||
|
||||
{$IFDEF TOKYOORBETTER}
|
||||
|
@ -247,6 +247,8 @@ type
|
||||
[Test]
|
||||
//[Category('this')]
|
||||
procedure TestStringToDateTime_Local;
|
||||
procedure TestStringToDateTime_NewYork;
|
||||
procedure TestStringToDateTime_Mumbai;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -2021,13 +2023,24 @@ begin
|
||||
12 + TTimeZone.Local.UtcOffset.Hours,
|
||||
12 + TTimeZone.Local.UtcOffset.Minutes, 12, 0), lDate);
|
||||
|
||||
// UTC "−05:00" for New York on standard time (UTC-05:00)
|
||||
lDate := ISOTimeStampToDateTime('2020-11-04T12:12:12-05:00');
|
||||
Assert.areEqual(DateTimeToStr(EncodeDateTime(2020, 11, 4, 17, 12, 12, 0)), DateTimeToStr(lDate));
|
||||
end;
|
||||
|
||||
procedure TTestUTC.TestStringToDateTime_Mumbai;
|
||||
var
|
||||
lDate: TDateTime;
|
||||
begin
|
||||
// UTC "+05:30" for Mumbai (UTC+05:30)
|
||||
lDate := ISOTimeStampToDateTime('2020-11-04T12:12:12+05:30');
|
||||
Assert.areEqual(DateTimeToStr(EncodeDateTime(2020, 11, 4, 6, 42, 12, 0)), DateTimeToStr(lDate));
|
||||
Assert.areEqual(DateTimeToStr(EncodeDateTime(2020, 11, 4, 7, 42, 12, 0)), DateTimeToStr(lDate));
|
||||
end;
|
||||
|
||||
procedure TTestUTC.TestStringToDateTime_NewYork;
|
||||
var
|
||||
lDate: TDateTime;
|
||||
begin
|
||||
// UTC "−05:00" for New York on standard time (UTC-05:00)
|
||||
lDate := ISOTimeStampToDateTime('2020-11-04T12:12:12-05:00');
|
||||
Assert.areEqual(DateTimeToStr(EncodeDateTime(2020, 11, 4, 18, 12, 12, 0)), DateTimeToStr(lDate));
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
Loading…
Reference in New Issue
Block a user