File tree Expand file tree Collapse file tree 2 files changed +25
-13
lines changed Expand file tree Collapse file tree 2 files changed +25
-13
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ interface
10
10
, fpjson
11
11
, fpjsonrtti
12
12
, fgl
13
+ , typinfo
13
14
;
14
15
15
16
const
@@ -46,6 +47,7 @@ THyperfineResult = class(TObject)
46
47
47
48
procedure setFromJSONData (const AJSONData: TJSONData);
48
49
procedure setFromJSONObject (const AJSONObject: TJSONObject);
50
+ procedure OnRestoreProperty (Sender: TObject; AObject: TObject; Info: PPropInfo; AValue: TJSONData; var Handled: Boolean);
49
51
protected
50
52
public
51
53
constructor Create;
@@ -176,12 +178,32 @@ procedure THyperfineResult.setFromJSONObject(const AJSONObject: TJSONObject);
176
178
jds: TJSONDestreamer;
177
179
begin
178
180
jds := TJSONDestreamer.Create(nil );
181
+ jds.OnRestoreProperty := @OnRestoreProperty;
179
182
try
180
183
jds.JSONToObject(AJSONObject.AsJSON, Self);
181
184
finally
182
185
jds.Free;
183
186
end ;
184
187
end ;
185
188
189
+ procedure THyperfineResult.OnRestoreProperty (Sender: TObject; AObject: TObject; Info: PPropInfo; AValue: TJSONData; var Handled: Boolean);
190
+ var
191
+ i: Integer;
192
+ begin
193
+ Handled := False;
194
+ if (Info^.Name = ' times' ) then
195
+ begin
196
+ Handled := True;
197
+ for i := 0 to AValue.Count - 1 do
198
+ THyperfineResult(AObject).times.Add(Avalue.Items[i].AsFloat);
199
+ end
200
+ else if (Info^.Name = ' exit_codes' ) then
201
+ begin
202
+ Handled := True;
203
+ for i := 0 to AValue.Count - 1 do
204
+ THyperfineResult(AObject).exit_codes.Add(Avalue.Items[i].AsInteger);
205
+ end ;
206
+ end ;
207
+
186
208
end .
187
209
Original file line number Diff line number Diff line change @@ -116,19 +116,9 @@ function TResults.FormatTime(ATime: Double): String;
116
116
begin
117
117
Result:= ' ' ;
118
118
intPart:= Trunc(ATime);
119
- minutes:= 0 ;
120
- if intPart >= 60 then
121
- begin
122
- repeat
123
- Inc(minutes);
124
- Dec(intPart, 60 );
125
- until intPart < 60 ;
126
- end ;
127
- millis:= Copy(
128
- FloatToStr(ATime),
129
- Pos(' .' , FloatToStr(ATime)) + 1 ,
130
- 4
131
- );
119
+ millis := FormatFloat(' 000' , Trunc((ATime - intPart) * 1000 ));
120
+ minutes := intPart div 60 ;
121
+ intPart := intPart mod 60 ;
132
122
Result:= Format(' %d:%d.%s' ,[
133
123
minutes,
134
124
intPart,
You can’t perform that action at this time.
0 commit comments