Home  |  Delphi .net Home  |  System.TimeSpan  |  Duration Method
  
Duration  
Method  
Returns the absolute value of the current TimeSpan
TimeSpan Structure
System NameSpace
CF1.  Function Duration : TimeSpan;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns a TimeSpan object which has the absolute value of the current TimeSpan.
 
In other words, the returned value is the absolute Duration of the current timespan, even if the span is back in time (negative value).
Microsoft MSDN Links
System
System.TimeSpan
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  span1, span2 : TimeSpan;
  result       : Integer;

begin
  span1 := TimeSpan.Create(0, -2, 30);  // -1.5 hours
  span2 := span1.Duration;

  Console.WriteLine('span1 = {0:F}', span1);
  Console.WriteLine('span2 = {0:F}', span2);

  Console.ReadLine;
end.
   span1 = -00:01:30
   span2 = 00:01:30
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author