System.TimeSpan.TTimeSpan

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

  TTimeSpan = record
  private
    FTicks: Int64;
  strict private
    function GetDays: Integer;
    function GetHours: Integer;
    function GetMinutes: Integer;
    function GetSeconds: Integer;
    function GetMilliseconds: Integer;
    function GetTotalDays: Double;
    function GetTotalHours: Double;
    function GetTotalMinutes: Double;
    function GetTotalSeconds: Double;
    function GetTotalMilliseconds: Double;
    class function GetScaledInterval(Value: Double; Scale: Integer): TTimeSpan; static;
    class constructor Create;
  strict private class var
    FMinValue: TTimeSpan{ = (FTicks: -9223372036854775808)};
    FMaxValue: TTimeSpan{ = (FTicks: $7FFFFFFFFFFFFFFF)};
    FZero: TTimeSpan;
  strict private const
    MillisecondsPerTick = 0.0001;
    SecondsPerTick = 1e-07;
    MinutesPerTick = 1.6666666666666667E-09;
    HoursPerTick = 2.7777777777777777E-11;
    DaysPerTick = 1.1574074074074074E-12;
    MillisPerSecond = 1000;
    MillisPerMinute = 60 * MillisPerSecond;
    MillisPerHour = 60 * MillisPerMinute;
    MillisPerDay = 24 * MillisPerHour;
    MaxSeconds = 922337203685;
    MinSeconds = -922337203685;
    MaxMilliseconds = 922337203685477;
    MinMilliseconds = -922337203685477;
  public const
    TicksPerMillisecond = 10000;
    TicksPerSecond = 1000 * Int64(TicksPerMillisecond);
    TicksPerMinute = 60 * Int64(TicksPerSecond);
    TicksPerHour = 60 * Int64(TicksPerMinute);
    TicksPerDay = 24 * TIcksPerHour;
  public
    constructor Create(ATicks: Int64); overload;
    constructor Create(Hours, Minutes, Seconds: Integer); overload;
    constructor Create(Days, Hours, Minutes, Seconds: Integer); overload;
    constructor Create(Days, Hours, Minutes, Seconds, Milliseconds: Integer); overload;
    function Add(const TS: TTimeSpan): TTimeSpan; overload;
    function Duration: TTimeSpan;
    function Negate: TTimeSpan;
    function Subtract(const TS: TTimeSpan): TTimeSpan; overload;
    function ToString: string;
    class function FromDays(Value: Double): TTimeSpan; static;
    class function FromHours(Value: Double): TTimeSpan; static;
    class function FromMinutes(Value: Double): TTimeSpan; static;
    class function FromSeconds(Value: Double): TTimeSpan; static;
    class function FromMilliseconds(Value: Double): TTimeSpan; static;
    class function FromTicks(Value: Int64): TTimeSpan; static;
    class function Subtract(const D1, D2: TDateTime): TTimeSpan; overload; static;
    class function Parse(const S: string): TTimeSpan; static;
    class function TryParse(const S: string; out Value: TTimeSpan): Boolean; static;
    class operator Add(const Left, Right: TTimeSpan): TTimeSpan;
    class operator Add(const Left: TTimeSpan; Right: TDateTime): TDateTime;
    class operator Add(const Left: TDateTime; Right: TTimeSpan): TDateTime;
    class operator Subtract(const Left, Right: TTimeSpan): TTimeSpan;
    class operator Subtract(const Left: TDateTime; Right: TTimeSpan): TDateTime;
    class operator Equal(const Left, Right: TTimeSpan): Boolean;
    class operator NotEqual(const Left, Right: TTimeSpan): Boolean;
    class operator GreaterThan(const Left, Right: TTimeSpan): Boolean;
    class operator GreaterThanOrEqual(const Left, Right: TTimeSpan): Boolean;
    class operator LessThan(const Left, Right: TTimeSpan): Boolean;
    class operator LessThanOrEqual(const Left, Right: TTimeSpan): Boolean;
    class operator Negative(const Value: TTimeSpan): TTimeSpan;
    class operator Positive(const Value: TTimeSpan): TTimeSpan;
    class operator Implicit(const Value: TTimeSpan): string;
    class operator Explicit(const Value: TTimeSpan): string;
    property Ticks: Int64 read FTicks;
    property Days: Integer read GetDays;
    property Hours: Integer read GetHours;
    property Minutes: Integer read GetMinutes;
    property Seconds: Integer read GetSeconds;
    property Milliseconds: Integer read GetMilliseconds;
    property TotalDays: Double read GetTotalDays;
    property TotalHours: Double read GetTotalHours;
    property TotalMinutes: Double read GetTotalMinutes;
    property TotalSeconds: Double read GetTotalSeconds;
    property TotalMilliseconds: Double read GetTotalMilliseconds;
    class property MinValue: TTimeSpan read FMinValue;
    class property MaxValue: TTimeSpan read FMaxValue;
    class property Zero: TTimeSpan read FZero;
  end;

C++

struct DECLSPEC_DRECORD TTimeSpan
{
private:
    __int64 FTicks;
private:
    int __fastcall GetDays();
    int __fastcall GetHours();
    int __fastcall GetMinutes();
    int __fastcall GetSeconds();
    int __fastcall GetMilliseconds();
    double __fastcall GetTotalDays();
    double __fastcall GetTotalHours();
    double __fastcall GetTotalMinutes();
    double __fastcall GetTotalSeconds();
    double __fastcall GetTotalMilliseconds();
    static TTimeSpan __fastcall GetScaledInterval(double Value, int Scale);
    static TTimeSpan FMinValue;
    static TTimeSpan FMaxValue;
    static TTimeSpan FZero;
    #define TTimeSpan_MillisecondsPerTick  (1.000000E-04)
    #define TTimeSpan_SecondsPerTick  (1.000000E-07)
    #define TTimeSpan_MinutesPerTick  (1.666667E-09)
    #define TTimeSpan_HoursPerTick  (2.777778E-11)
    #define TTimeSpan_DaysPerTick  (1.157407E-12)
    static const System::Word MillisPerSecond = System::Word(0x3e8);
    static const System::Word MillisPerMinute = System::Word(0xea60);
    static const int MillisPerHour = int(0x36ee80);
    static const int MillisPerDay = int(0x5265c00);
    static const __int64 MaxSeconds = 0x000000d6bf94d5e5LL;
    static const __int64 MinSeconds = -0x000000d6bf94d5e5LL;
    static const __int64 MaxMilliseconds = 0x000346dc5d638865LL;
    static const __int64 MinMilliseconds = -0x000346dc5d638865LL;
public:
    static const System::Word TicksPerMillisecond = System::Word(0x2710);
    static const __int64 TicksPerSecond = 0x0000000000989680LL;
    static const __int64 TicksPerMinute = 0x0000000023c34600LL;
    static const __int64 TicksPerHour = 0x0000000861c46800LL;
    static const __int64 TicksPerDay = 0x000000c92a69c000LL;
    __fastcall TTimeSpan(__int64 ATicks)/* overload */;
    __fastcall TTimeSpan(int Hours, int Minutes, int Seconds)/* overload */;
    __fastcall TTimeSpan(int Days, int Hours, int Minutes, int Seconds)/* overload */;
    __fastcall TTimeSpan(int Days, int Hours, int Minutes, int Seconds, int Milliseconds)/* overload */;
    TTimeSpan __fastcall Add(const TTimeSpan &TS)/* overload */;
    TTimeSpan __fastcall Duration();
    TTimeSpan __fastcall Negate();
    TTimeSpan __fastcall Subtract(const TTimeSpan &TS)/* overload */;
    System::UnicodeString __fastcall ToString();
    static TTimeSpan __fastcall FromDays(double Value);
    static TTimeSpan __fastcall FromHours(double Value);
    static TTimeSpan __fastcall FromMinutes(double Value);
    static TTimeSpan __fastcall FromSeconds(double Value);
    static TTimeSpan __fastcall FromMilliseconds(double Value);
    static TTimeSpan __fastcall FromTicks(__int64 Value);
    static TTimeSpan __fastcall Subtract(const System::TDateTime D1, const System::TDateTime D2)/* overload */;
    static TTimeSpan __fastcall Parse(const System::UnicodeString S);
    static bool __fastcall TryParse(const System::UnicodeString S, /* out */ TTimeSpan &Value);
    static TTimeSpan __fastcall _op_Addition(const TTimeSpan &Left, const TTimeSpan &Right);
    TTimeSpan __fastcall operator+(const TTimeSpan& __rhs) { return TTimeSpan::_op_Addition(*this, __rhs); };
    static System::TDateTime __fastcall _op_Addition(const TTimeSpan &Left, System::TDateTime Right);
    System::TDateTime __fastcall operator+(const System::TDateTime& __rhs) { return TTimeSpan::_op_Addition(*this, __rhs); };
    static System::TDateTime __fastcall _op_Addition(const System::TDateTime Left, const TTimeSpan &Right);
    static TTimeSpan __fastcall _op_Subtraction(const TTimeSpan &Left, const TTimeSpan &Right);
    TTimeSpan __fastcall operator-(const TTimeSpan& __rhs) { return TTimeSpan::_op_Subtraction(*this, __rhs); };
    static System::TDateTime __fastcall _op_Subtraction(const System::TDateTime Left, const TTimeSpan &Right);
    static bool __fastcall _op_Equality(const TTimeSpan &Left, const TTimeSpan &Right);
    bool __fastcall operator==(const TTimeSpan& __rhs) { return TTimeSpan::_op_Equality(*this, __rhs); };
    static bool __fastcall _op_Inequality(const TTimeSpan &Left, const TTimeSpan &Right);
    bool __fastcall operator!=(const TTimeSpan& __rhs) { return TTimeSpan::_op_Inequality(*this, __rhs); };
    static bool __fastcall _op_GreaterThan(const TTimeSpan &Left, const TTimeSpan &Right);
    bool __fastcall operator>(const TTimeSpan& __rhs) { return TTimeSpan::_op_GreaterThan(*this, __rhs); };
    static bool __fastcall _op_GreaterThanOrEqual(const TTimeSpan &Left, const TTimeSpan &Right);
    bool __fastcall operator>=(const TTimeSpan& __rhs) { return TTimeSpan::_op_GreaterThanOrEqual(*this, __rhs); };
    static bool __fastcall _op_LessThan(const TTimeSpan &Left, const TTimeSpan &Right);
    bool __fastcall operator<(const TTimeSpan& __rhs) { return TTimeSpan::_op_LessThan(*this, __rhs); };
    static bool __fastcall _op_LessThanOrEqual(const TTimeSpan &Left, const TTimeSpan &Right);
    bool __fastcall operator<=(const TTimeSpan& __rhs) { return TTimeSpan::_op_LessThanOrEqual(*this, __rhs); };
    static TTimeSpan __fastcall _op_UnaryNegation(const TTimeSpan &Value);
    TTimeSpan __fastcall operator-() { return TTimeSpan::_op_UnaryNegation(*this); };
    static TTimeSpan __fastcall _op_UnaryPlus(const TTimeSpan &Value);
    TTimeSpan __fastcall operator+() { return TTimeSpan::_op_UnaryPlus(*this); };
    __fastcall operator System::UnicodeString();
    __property __int64 Ticks = {read=FTicks};
    __property int Days = {read=GetDays};
    __property int Hours = {read=GetHours};
    __property int Minutes = {read=GetMinutes};
    __property int Seconds = {read=GetSeconds};
    __property int Milliseconds = {read=GetMilliseconds};
    __property double TotalDays = {read=GetTotalDays};
    __property double TotalHours = {read=GetTotalHours};
    __property double TotalMinutes = {read=GetTotalMinutes};
    __property double TotalSeconds = {read=GetTotalSeconds};
    __property double TotalMilliseconds = {read=GetTotalMilliseconds};
    /* static */ __property TTimeSpan MinValue = {read=FMinValue};
    /* static */ __property TTimeSpan MaxValue = {read=FMaxValue};
    /* static */ __property TTimeSpan Zero = {read=FZero};
private:
public:
    TTimeSpan() {}
};

Properties

Type Visibility Source Unit Parent
record
struct
public
System.TimeSpan.pas
System.TimeSpan.hpp
System.TimeSpan System.TimeSpan

Description

Describes a time interval.

TTimeSpan is a data structure used for holding information about a period of time. A TTimeSpan object can be a positive or a negative time interval measured in days, hours, minutes, seconds, milliseconds, and ticks. The time period represented can be positive or negative and can range from the values stored in the read only properties MinValue to MaxValue. The smallest unit of time is a tick which is 100 nanoseconds. The largest unit of time is a day.

See Also