{$MODE FPC}
{$MODESWITCH RESULT}
{$MODESWITCH ADVANCEDRECORDS}
unit dchrono;

interface

type
TConst1 = record
  const Value = 1;
end;

TConst1000 = record
  const Value = 1000;
end;

TConst1000000 = record
  const Value = 1000000;
end;

TConst1000000000 = record
  const Value = 1000000000;
end;

TConst60 = record
  const Value = 60;
end;

TConst360 = record
  const Value = 360;
end;

TConst86400 = record
  const Value = 86400;
end;

generic TDuration<T, P, Q> = record
private
  FValue: T;
public
  function Count: T;
end;

TSeconds = specialize TDuration<PtrInt, TConst1, TConst1>;
TMilliSeconds = specialize TDuration<PtrInt, TConst1, TConst1000>;
TMicroSeconds = specialize TDuration<PtrInt, TConst1, TConst1000000>;
TNanoSeconds = specialize TDuration<PtrInt, TConst1, TConst1000000000>;
TMinues = specialize TDuration<PtrInt, TConst60, TConst1>;
THours = specialize TDuration<PtrInt, TConst360, TConst1>;
TDays = specialize TDuration<PtrInt, TConst86400, TConst1>;

implementation

function TDuration.Count: T;
begin
  Result := FValue;
end;

end.
