Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatação Data e Hora #82

Closed
mbertolani opened this issue Jan 25, 2021 · 1 comment
Closed

Formatação Data e Hora #82

mbertolani opened this issue Jan 25, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@mbertolani
Copy link
Contributor

A classe não publica as propriedades "FormatTime" e "FormatDateTime"

segue modificações necessárias:

-- Config.pas

TDataSetSerializeConfigExport = class
private
FExportNullValues: Boolean;
FExportNullAsEmptyString: Boolean;
FExportOnlyFieldsVisible: Boolean;
FExportEmptyDataSet: Boolean;
FFormatCurrency: string;
FFormatDate: string;
FFormatTime: string;
FFormatDateTime: string;

FExportChildDataSetAsJsonObject: Boolean;
public
constructor Create;
property FormatTime: string read FFormatTime write FFormatTime;
property FormatDateTime: string read FFormatDateTime write FFormatDateTime;

property FormatDate: string read FFormatDate write FFormatDate;
property FormatCurrency: string read FFormatCurrency write FFormatCurrency;
property ExportOnlyFieldsVisible: Boolean read FExportOnlyFieldsVisible write FExportOnlyFieldsVisible;
property ExportNullValues: Boolean read FExportNullValues write FExportNullValues;
property ExportNullAsEmptyString: Boolean read FExportNullAsEmptyString write FExportNullAsEmptyString;
property ExportEmptyDataSet: Boolean read FExportEmptyDataSet write FExportEmptyDataSet;
property ExportChildDataSetAsJsonObject: Boolean read FExportChildDataSetAsJsonObject write FExportChildDataSetAsJsonObject;
end;

constructor TDataSetSerializeConfigExport.Create;
begin
FExportNullValues := True;
FExportNullAsEmptyString:= False;
FExportOnlyFieldsVisible := True;
ExportEmptyDataSet := False;
FFormatCurrency := EmptyStr;
FFormatTime := 'hh:nn:ss.zzz';
FFormatDateTime := 'yyyy-mm-dd hh:nn:ss.zzz';

FFormatDate := 'YYYY-MM-DD';
FExportChildDataSetAsJsonObject := False;
end;

-- Export.pas

  TFieldType.ftDateTime:
       Result.{$IF DEFINED(FPC)}Add{$ELSE}AddPair{$ENDIF}(LKey, TJSONString.Create(FormatDateTime(TDataSetSerializeConfig.GetInstance.Export.FormatDateTime, LField.AsDateTime)));
   TFieldType.ftTimeStamp:
       Result.{$IF DEFINED(FPC)}Add{$ELSE}AddPair{$ENDIF}(LKey, TJSONString.Create(DateToISO8601(LField.AsDateTime, TDataSetSerializeConfig.GetInstance.DateInputIsUTC)));
   TFieldType.ftTime:
       Result.{$IF DEFINED(FPC)}Add{$ELSE}AddPair{$ENDIF}(LKey, TJSONString.Create(FormatDateTime(TDataSetSerializeConfig.GetInstance.Export.FormatTime, LField.AsDateTime)));
   TFieldType.ftDate:
       Result.{$IF DEFINED(FPC)}Add{$ELSE}AddPair{$ENDIF}(LKey, TJSONString.Create(FormatDateTime(TDataSetSerializeConfig.GetInstance.Export.FormatDate, LField.AsDateTime)));
@viniciussanchez viniciussanchez added the enhancement New feature or request label Jan 26, 2021
@viniciussanchez
Copy link
Owner

Obrigado

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants