Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtCore.QTime Class Reference

The QTime class provides clock time functions. More...

Inheritance diagram for QtCore.QTime:
Collaboration diagram for QtCore.QTime:

Public Types

enum  TimeFlag
 

Public Member Functions

override bool Equals (object o)
 
override int GetHashCode ()
 
 QTime ()
 
 
 QTime (QTime copy)
 
 
 QTime (int h, int m, int s=0, int ms=0)
 
 
virtual void CreateProxy ()
 
new QTime AddMSecs (int ms)
 
 
new QTime AddSecs (int secs)
 
 
new int Elapsed ()
 
 
new int Hour ()
 
 
new bool IsNull ()
 
 
new bool IsValid ()
 
 
new int Minute ()
 
 
new int Msec ()
 
 
new int MsecsTo (QTime arg1)
 
 
new int Restart ()
 
 
new int Second ()
 
 
new int SecsTo (QTime arg1)
 
 
new bool SetHMS (int h, int m, int s, int ms=0)
 
 
new void Start ()
 
 
override string ToString ()
 
 
new string ToString (Qt.DateFormat f=Qt.DateFormat.TextDate)
 
 
new string ToString (string format)
 
 
new void Dispose ()
 

Static Public Member Functions

static QTime CurrentTime ()
 
 
static QTime FromString (string s, Qt.DateFormat f=Qt.DateFormat.TextDate)
 
 
static QTime FromString (string s, string format)
 
 
static bool IsValid (int h, int m, int s, int ms=0)
 
 
static bool operator!= (QTime arg1, QTime arg2)
 
 
static bool operator< (QTime arg1, QTime arg2)
 
 
static bool operator<= (QTime arg1, QTime arg2)
 
 
static bool operator== (QTime arg1, QTime arg2)
 
 
static bool operator> (QTime arg1, QTime arg2)
 
 
static bool operator>= (QTime arg1, QTime arg2)
 
 

Protected Member Functions

 QTime (System.Type dummy)
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

virtual System.IntPtr SmokeObject [get, set]
 

Detailed Description

The QTime class provides clock time functions.

A QTime object contains a clock time, i.e. the number of hours, minutes, seconds, and milliseconds since midnight. It can read the current time from the system clock and measure a span of elapsed time. It provides functions for comparing times and for manipulating a time by adding a number of milliseconds.

QTime uses the 24-hour clock format; it has no concept of AM/PM. Unlike QDateTime, QTime knows nothing about time zones or daylight savings time (DST).

A QTime object is typically created either by giving the number of hours, minutes, seconds, and milliseconds explicitly, or by using the static function currentTime(), which creates a QTime object that contains the system's local time. Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.

The hour(), minute(), second(), and msec() functions provide access to the number of hours, minutes, seconds, and milliseconds of the time. The same information is provided in textual format by the toString() function.

QTime provides a full set of operators to compare two QTime objects. One time is considered smaller than another if it is earlier than the other.

The time a given number of seconds or milliseconds later than a given time can be found using the addSecs() or addMSecs() functions. Correspondingly, the number of seconds or milliseconds between two times can be found using secsTo() or msecsTo().

QTime can be used to measure a span of elapsed time using the start(), restart(), and elapsed() functions.

See also QDate and QDateTime.

Member Enumeration Documentation

Constructor & Destructor Documentation

QtCore.QTime.QTime ( System.Type  dummy)
protected
QtCore.QTime.QTime ( )

Constructs a null time object. A null time can be a QTime(0, 0, 0, 0) (i.e., midnight) object, except that isNull() returns true and isValid() returns false.

See also isNull() and isValid().

QtCore.QTime.QTime ( QTime  copy)

Constructs a null time object. A null time can be a QTime(0, 0, 0, 0) (i.e., midnight) object, except that isNull() returns true and isValid() returns false.

See also isNull() and isValid().

QtCore.QTime.QTime ( int  h,
int  m,
int  s = 0,
int  ms = 0 
)

Constructs a time with hour h, minute m, seconds s and milliseconds ms.

h must be in the range 0 to 23, m and s must be in the range 0 to 59, and ms must be in the range 0 to 999.

See also isValid().

Member Function Documentation

new QTime QtCore.QTime.AddMSecs ( int  ms)

Returns a QTime object containing a time ms milliseconds later than the time of this object (or earlier if ms is negative).

Note that the time will wrap if it passes midnight. See addSecs() for an example.

See also addSecs(), msecsTo(), and QDateTime::addMSecs().

new QTime QtCore.QTime.AddSecs ( int  secs)

Returns a QTime object containing a time s seconds later than the time of this object (or earlier if s is negative).

Note that the time will wrap if it passes midnight.

Example:

QTime n(14, 0, 0); // n == 14:00:00

QTime t;

t = n.addSecs(70); // t == 14:01:10

t = n.addSecs(-70); // t == 13:58:50

t = n.addSecs(10 * 60 * 60 + 5); // t == 00:00:05

t = n.addSecs(-15 * 60 * 60); // t == 23:00:00

See also addMSecs(), secsTo(), and QDateTime::addSecs().

virtual void QtCore.QTime.CreateProxy ( )
virtual
static QTime QtCore.QTime.CurrentTime ( )
static

Returns the current time as reported by the system clock.

Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.

new void QtCore.QTime.Dispose ( )
new int QtCore.QTime.Elapsed ( )

Returns the number of milliseconds that have elapsed since the last time start() or restart() was called.

Note that the counter wraps to zero 24 hours after the last call to start() or restart.

Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.

Warning: If the system's clock setting has been changed since the last time start() or restart() was called, the result is undefined. This can happen when daylight savings time is turned on or off.

See also start() and restart().

override bool QtCore.QTime.Equals ( object  o)
static QTime QtCore.QTime.FromString ( string  s,
Qt.DateFormat  f = Qt.DateFormat.TextDate 
)
static

Returns the time represented in the string as a QTime using the format given, or an invalid time if this is not possible.

Note that fromString() uses a "C" locale encoded string to convert milliseconds to a float value. If the default locale is not "C", this may result in two conversion attempts (if the conversion fails for the default locale). This should be considered an implementation detail.

static QTime QtCore.QTime.FromString ( string  s,
string  format 
)
static

Returns the QTime represented by the string, using the format given, or an invalid time if the string cannot be parsed.

These expressions may be used for the format:

ExpressionOutput

h the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)

hh the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)

m the minute without a leading zero (0 to 59)

mm the minute with a leading zero (00 to 59)

s the second without a leading zero (0 to 59)

ss the second with a leading zero (00 to 59)

z the milliseconds without leading zeroes (0 to 999)

zzz the milliseconds with leading zeroes (000 to 999)

AP interpret as an AM/PM time. AP must be either "AM" or "PM".

ap Interpret as an AM/PM time. ap must be either "am" or "pm".

All other input characters will be treated as text. Any sequence of characters that are enclosed in single quotes will also be treated as text and not be used as an expression.

QTime time = QTime::fromString("1mm12car00", "m'mm'hcarss");

// time is 12:01.00

If the format is not satisfied an invalid QTime is returned. Expressions that do not expect leading zeroes to be given (h, m, s and z) are greedy. This means that they will use two digits even if this puts them outside the range of accepted values and leaves too few digits for other sections. For example, the following string could have meant 00:07:10, but the m will grab two digits, resulting in an invalid time:

QTime time = QTime::fromString("00:710", "hh:ms"); // invalid

Any field that is not represented in the format will be set to zero. For example:

QTime time = QTime::fromString("1.30", "m.s");

// time is 00:01:30.000

QDateTime::toString() QTime::toString()

See also QDateTime::fromString(), QDate::fromString(), and QDate::toString().

override int QtCore.QTime.GetHashCode ( )
new int QtCore.QTime.Hour ( )

Returns the hour part (0 to 23) of the time.

See also minute(), second(), and msec().

new bool QtCore.QTime.IsNull ( )

Returns true if the time is null (i.e., the QTime object was constructed using the default constructor); otherwise returns false. A null time is also an invalid time.

See also isValid().

new bool QtCore.QTime.IsValid ( )

Returns true if the time is valid; otherwise returns false. For example, the time 23:30:55.746 is valid, but 24:12:30 is invalid.

See also isNull().

static bool QtCore.QTime.IsValid ( int  h,
int  m,
int  s,
int  ms = 0 
)
static

This is an overloaded function.

Returns true if the specified time is valid; otherwise returns false.

The time is valid if h is in the range 0 to 23, m and s are in the range 0 to 59, and ms is in the range 0 to 999.

Example:

QTime::isValid(21, 10, 30); // returns true

QTime::isValid(22, 5, 62); // returns false

new int QtCore.QTime.Minute ( )

Returns the minute part (0 to 59) of the time.

See also hour(), second(), and msec().

new int QtCore.QTime.Msec ( )

Returns the millisecond part (0 to 999) of the time.

See also hour(), minute(), and second().

new int QtCore.QTime.MsecsTo ( QTime  arg1)

Returns the number of milliseconds from this time to t. If t is earlier than this time, the number of milliseconds returned is negative.

Because QTime measures time within a day and there are 86400 seconds in a day, the result is always between -86400000 and 86400000 ms.

See also secsTo(), addMSecs(), and QDateTime::msecsTo().

static bool QtCore.QTime.operator!= ( QTime  arg1,
QTime  arg2 
)
static

Returns true if this time is different from t; otherwise returns false.

static bool QtCore.QTime.operator< ( QTime  arg1,
QTime  arg2 
)
static

Returns true if this time is earlier than t; otherwise returns false.

static bool QtCore.QTime.operator<= ( QTime  arg1,
QTime  arg2 
)
static

Returns true if this time is earlier than or equal to t; otherwise returns false.

static bool QtCore.QTime.operator== ( QTime  arg1,
QTime  arg2 
)
static

Returns true if this time is equal to t; otherwise returns false.

static bool QtCore.QTime.operator> ( QTime  arg1,
QTime  arg2 
)
static

Returns true if this time is later than t; otherwise returns false.

static bool QtCore.QTime.operator>= ( QTime  arg1,
QTime  arg2 
)
static

Returns true if this time is later than or equal to t; otherwise returns false.

new int QtCore.QTime.Restart ( )

Sets this time to the current time and returns the number of milliseconds that have elapsed since the last time start() or restart() was called.

This function is guaranteed to be atomic and is thus very handy for repeated measurements. Call start() to start the first measurement, and restart() for each later measurement.

Note that the counter wraps to zero 24 hours after the last call to start() or restart().

Warning: If the system's clock setting has been changed since the last time start() or restart() was called, the result is undefined. This can happen when daylight savings time is turned on or off.

See also start(), elapsed(), and currentTime().

new int QtCore.QTime.Second ( )

Returns the second part (0 to 59) of the time.

See also hour(), minute(), and msec().

new int QtCore.QTime.SecsTo ( QTime  arg1)

Returns the number of seconds from this time to t. If t is earlier than this time, the number of seconds returned is negative.

Because QTime measures time within a day and there are 86400 seconds in a day, the result is always between -86400 and 86400.

secsTo() does not take into account any milliseconds.

See also addSecs() and QDateTime::secsTo().

new bool QtCore.QTime.SetHMS ( int  h,
int  m,
int  s,
int  ms = 0 
)

Sets the time to hour h, minute m, seconds s and milliseconds ms.

h must be in the range 0 to 23, m and s must be in the range 0 to 59, and ms must be in the range 0 to 999. Returns true if the set time is valid; otherwise returns false.

See also isValid().

new void QtCore.QTime.Start ( )

Sets this time to the current time. This is practical for timing:

QTime t;

t.start();

some_lengthy_task();

qDebug("Time elapsed: d ms", t.elapsed());

See also restart(), elapsed(), and currentTime().

override string QtCore.QTime.ToString ( )

See also QDateTime::fromString(), QDate::fromString(), and QDate::toString().

new string QtCore.QTime.ToString ( Qt.DateFormat  f = Qt.DateFormat.TextDate)

See also QDateTime::fromString(), QDate::fromString(), and QDate::toString().

new string QtCore.QTime.ToString ( string  format)

Returns the time as a string. The format parameter determines the format of the result string.

These expressions may be used:

ExpressionOutput

h the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)

hh the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)

H the hour without a leading zero (0 to 23, even with AM/PM display)

HH the hour with a leading zero (00 to 23, even with AM/PM display)

m the minute without a leading zero (0 to 59)

mm the minute with a leading zero (00 to 59)

s the second without a leading zero (0 to 59)

ss the second with a leading zero (00 to 59)

z the milliseconds without leading zeroes (0 to 999)

zzz the milliseconds with leading zeroes (000 to 999)

AP or A use AM/PM display. AP will be replaced by either "AM" or "PM".

ap or a use am/pm display. ap will be replaced by either "am" or "pm".

t the timezone (for example "CEST")

All other input characters will be ignored. Any sequence of characters that are enclosed in singlequotes will be treated as text and not be used as an expression. Two consecutive singlequotes ("''") are replaced by a singlequote in the output.

Example format strings (assuming that the QTime is 14:13:09.042)

FormatResult

hh:mm:ss.zzz 14:13:09.042

h:m:s ap 2:13:9 pm

H:m:s a 14:13:9 pm

If the datetime is invalid, an empty string will be returned. If format is empty, the default format "hh:mm:ss" is used.

See also QDate::toString() and QDateTime::toString().

Member Data Documentation

SmokeInvocation QtCore.QTime.interceptor
protected

Property Documentation

virtual System.IntPtr QtCore.QTime.SmokeObject
getset