-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathWvN.GitLens.Utils.pas
26 lines (19 loc) · 1.09 KB
/
WvN.GitLens.Utils.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
unit WvN.GitLens.Utils;
interface
function TimeSpanToShortStr(span: TDateTime): String;
implementation
uses
System.DateUtils, System.SysUtils, System.StrUtils;
function TimeSpanToShortStr(span: TDateTime): String;
begin
Result := '';
var ms:int64 := abs(Round(span / OneMilliSecond));
if ms < 1000 then Result := (ms div 1 ).ToString + ' milliseconds'
else if ms < 1000*60 *5 then Result := (ms div (1000 )).ToString + ' seconds'
else if ms < 1000*60*60 *5 then Result := (ms div (1000*60 )).ToString + ' minutes'
else if ms < 1000*60*60*24 *2 then Result := (ms div (1000*60*60 )).ToString + ' hours'
else if ms < int64(1000*60*60*24) *60 then Result := (ms div (1000*60*60*24 )).ToString + ' days'
else if ms < int64(1000*60*60*24)*365 *2 then Result := (ms div (int64(1000*60*60*24)*30 )).ToString + ' months'
else Result := (ms div (int64(1000*60*60*24)*365)).ToString + ' years';
end;
end.