C12Adapter Opensource C++ Interface
|
Time span represents the difference between two times, a duration. More...
Public Member Functions | |
MTimeSpan () | |
Default constructor that initializes the object to no span, no duration. | |
MTimeSpan (int secs, int mins=0, int hours=0, int days=0) | |
Constructor, which explicitly sets the time span data, including days. More... | |
MTimeSpan (const MTime &t1, const MTime &t2) | |
Constructor, which initializes the object to a difference between the two time stamps. More... | |
MTimeSpan (const MTimeSpan &other) | |
Copy constructor. | |
virtual | ~MTimeSpan () |
Object destructor. | |
bool | IsNull () const |
Whether the object represents no duration. | |
void | SetToNull () |
Set the span to null. | |
MStdString | AsFormattedString (MConstChars formatString) const |
AsFormattedString the time span object as string. More... | |
void | Set (int secs, int mins=0, int hours=0, int days=0) |
Set all parameters for the time span. More... | |
int | GetDays () const |
Get days fraction of the time span, total 24 hour portions in the duration. More... | |
int | GetHours () const |
Get hours part of the time span, -23 to 23. More... | |
int | GetMinutes () const |
Get minutes fraction of the time span. More... | |
int | GetSeconds () const |
Get seconds fraction of the time span. More... | |
int | ToHours () const |
Convert time span to hours. More... | |
int | ToMinutes () const |
Convert time span to minutes. More... | |
int | ToSeconds () const |
Convert time span to seconds. More... | |
int | Compare (const MTimeSpan &other) const |
Compare two time spans, ternary comparison service. More... | |
int | CompareWithVariant (const MVariant &other) const |
Same as Compare, but uses a variant as the other type. More... | |
MVariant | Add (const MVariant &) const |
Add an object to time span object and return the result, reflection-enabling service. More... | |
MVariant | Subtract (const MVariant &) const |
Subtract an object to time span object and return the result, reflection-enabling service. More... | |
MVariant | Multiply (int numberOfTimes) const |
Multiply a time span object with the given number of times, return the result. More... | |
MVariant | Divide (int numberOfTimes) const |
Divide a time span object with the given number of times, return the result. More... | |
MVariant | NewClone () const |
Reflection-enabling copy constructor. More... | |
void | DoSet1 (int seconds) |
Set the new time span value from the given number if seconds. More... | |
void | DoSet3 (int seconds, int minutes, int hours) |
Set the new time span value from the given time. More... | |
virtual unsigned | GetEmbeddedSizeof () const |
Time span is an embedded object type, therefore return its size in bytes. More... | |
MTimeSpan & | operator= (const MTimeSpan &other) |
Assignment operator. More... | |
MTimeSpan & | operator+= (const MTimeSpan &other) |
Assignment with addition operator. More... | |
MTimeSpan & | operator-= (const MTimeSpan &other) |
Assignment with subtraction operator. More... | |
MTimeSpan & | operator*= (int numberOfTimes) |
Assignment with multiplication operator. More... | |
MTimeSpan & | operator/= (int numberOfTimes) |
Assignment with division operator. More... | |
bool | operator== (const MTimeSpan &other) const |
Equality comparison operator. More... | |
bool | operator!= (const MTimeSpan &other) const |
Inequality comparison operator. More... | |
bool | operator< (const MTimeSpan &other) const |
Less-than operator. More... | |
bool | operator> (const MTimeSpan &other) const |
Greater-than operator. More... | |
bool | operator<= (const MTimeSpan &other) const |
Less than or equal to operator. More... | |
bool | operator>= (const MTimeSpan &other) const |
Greater than or equal to operator. More... | |
MTimeSpan | operator- () const |
Negation operator, does not modify self. | |
MTimeSpan | operator/ (int numberOfTimes) const |
Division operator. More... | |
MTimeSpan | operator- (const MTimeSpan &other) const |
Subtraction operator. More... | |
MTimeSpan | operator+ (const MTimeSpan &other) const |
Add operator. More... | |
MStdString | AsString () const |
void | SetAsString (const MStdString &) |
![]() | |
virtual | ~MObject () |
Object destructor. | |
virtual const MClass * | GetClass () const =0 |
Get the final class of the object. More... | |
bool | IsEmbeddedObject () const |
Tell if the object is of embedded kind. More... | |
SHOW_INTERNAL MVariant | Call (const MStdString &name, const MVariant ¶ms) |
Call the object service with parameters, given as variant. More... | |
MVariant | Call0 (const MStdString &name) |
Call the object service with no parameters. More... | |
MVariant | Call1 (const MStdString &name, const MVariant &p1) |
Call the object service with one parameter. More... | |
MVariant | Call2 (const MStdString &name, const MVariant &p1, const MVariant &p2) |
Call the object service with two parameter. More... | |
MVariant | Call3 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3) |
Call the object service with three parameter. More... | |
MVariant | Call4 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4) |
Call the object service with four parameter. More... | |
MVariant | Call5 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5) |
Call the object service with five parameter. More... | |
MVariant | Call6 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5, const MVariant &p6) |
Call the object service with six parameter. More... | |
virtual MVariant | CallV (const MStdString &name, const MVariant::VariantVector ¶ms) |
Call the object service with parameters, given as variant vector. More... | |
virtual bool | IsPropertyPresent (const MStdString &name) const |
Tell if the property with the given name exists. | |
virtual bool | IsServicePresent (const MStdString &name) const |
Tell if the service with the given name exists. | |
virtual MVariant | GetProperty (const MStdString &name) const |
Get the property value using name of the property. More... | |
virtual void | SetProperty (const MStdString &name, const MVariant &value) |
Set the property using name of the property, and value. More... | |
virtual MStdStringVector | GetAllPropertyNames () const |
Return the list of publicly available properties, persistent or not. More... | |
virtual MStdStringVector | GetAllPersistentPropertyNames () const |
Return the list of persistent properties. More... | |
virtual void | SetPersistentPropertiesToDefault () |
Set the persistent properties of the object to their default values. More... | |
virtual MVariant | GetPersistentPropertyDefaultValue (const MStdString &name) const |
Get the default value of persistent property with the name given. More... | |
virtual void | SetPersistentPropertyToDefault (const MStdString &name) |
Set the persistent property with the name given to default value. More... | |
virtual const char * | GetType () const |
Get the name of the type for the object (could be the same as class name). | |
virtual void | SetType (const MStdString &) |
Intentionally, it will set the name of the type for the object, but the service will not allow setting the name to anything other than the current name. More... | |
virtual void | Validate () |
Validate internal structures of the object. More... | |
Friends | |
class M_CLASS | MTime |
MTimeSpan | operator* (const MTimeSpan &p1, int p2) |
Assign-multiplicative operator. | |
MTimeSpan | operator* (int p1, const MTimeSpan &p2) |
Assign-multiplicative operator. | |
M_FUNC MTime & | operator+= (MTime &, const MTimeSpan &) |
Add time span to this time and assign the result back to time. More... | |
M_FUNC MTime & | operator-= (MTime &, const MTimeSpan &) |
Subtract time span to this time and assign the result back to time. More... | |
M_FUNC MTime | operator+ (const MTime &, const MTimeSpan &) |
Add a time span to time value, and without changing the two return the result. More... | |
M_FUNC MTime | operator+ (const MTimeSpan &, const MTime &) |
Add a time span to time value, and without changing the two return the result. More... | |
M_FUNC MTime | operator- (const MTime &, const MTimeSpan &) |
Subtract a time span from time value, and without changing the two return the result. More... | |
M_FUNC MTimeSpan | operator- (const MTime &t1, const MTime &t2) |
Subtract one time value from another and return the resultant time span. More... | |
Additional Inherited Members | |
![]() | |
static const MClass * | GetStaticClass () |
Get the declared class of this particular object. More... | |
static bool | IsClassPresent (const MStdString &name) |
Tells if the given class name is available. More... | |
![]() | |
static const MClass | s_class |
Class of MObject. | |
![]() | |
MObject () | |
Object constructor, protected as the class is abstract. | |
void | DoSetPersistentPropertiesToDefault (const MClass *staticClass) |
Set the persistent properties to their default values for one object provided the class for that object. More... | |
Time span represents the difference between two times, a duration.
Time span would be a result of subtraction of two MTime values, or it can be initialized directly. Time span can be convenient to keep the date and time separately from each other. Time span can be negative.
While null value of MTime cannot be manipulated with, null value of time span is a valid value, zero span, which corresponds to no difference between times. Default constructor initializes time span with such null value.
Time span is independent from time zone and daylight saving status. In fact, it can be used to represent a difference in time zones or a DST shift. For example, this is how the time is converted to time in another time zone:
|
inlineexplicit |
Constructor, which explicitly sets the time span data, including days.
Beware that the order of parameters is reverse to what is usually assumed. Negative values represent negative time span. Also, no check is done for overflow condition (when number of days is so big that it does not fit in 67 years range supported by this class).
secs | Seconds of time span. |
mins | Minutes of time span. |
hours | Hours of time span. |
days | Days of time span. |
Constructor, which initializes the object to a difference between the two time stamps.
Equivalent to (t1 - t2).
Add an object to time span object and return the result, reflection-enabling service.
MStdString MTimeSpan::AsFormattedString | ( | MConstChars | formatString | ) | const |
AsFormattedString the time span object as string.
The supported formats are:
By default, formats d, D, h, H, m, M, s and S always give unsigned, absolute values, even if the span is negative. One can use N and n format to add sign in a desired place. Alternatively, when format has a minus sign character like %-d, %-D, %-h, %-H, %-m, %-M, %-s or %-S, the values will have sign if they are negative. For other formats, the minus sign character is ignored.
MStdString MTimeSpan::AsString | ( | ) | const |
Represent time span as string.
Zero time span is represented as "00:00:00". If the string fits in one day, the property will have only hours, minutes and seconds, such as "00:00:01" (one second into the future), "23:00:00" (23 hours into the future). Otherwise, if the time is bigger than one day it will have number of days at the beginning, separated by a blank, such as "1000 00:00:00" for 1000 days into the future. Negative time span (referring to the past) will have a minus sign at the beginning, such as "-00:01:00" for one minute into the past, and "-100 00:00:00" for 100 days into the past.
The given time span string syntax is this:
Examples of valid string inputs:
|
inline |
Compare two time spans, ternary comparison service.
The exact value returned is not specified, only the signed value or zero.
other | Other variant to compare with. |
int MTimeSpan::CompareWithVariant | ( | const MVariant & | other | ) | const |
Same as Compare, but uses a variant as the other type.
other | If this is a numeric value, then it is the number of seconds. If this is an object of type MTimeSpan, then a regular Compare is called. |
MVariant MTimeSpan::Divide | ( | int | numberOfTimes | ) | const |
Divide a time span object with the given number of times, return the result.
void MTimeSpan::DoSet1 | ( | int | seconds | ) |
Set the new time span value from the given number if seconds.
seconds | Seconds value to initialize time span. |
void MTimeSpan::DoSet3 | ( | int | seconds, |
int | minutes, | ||
int | hours | ||
) |
Set the new time span value from the given time.
seconds | Seconds value of the result time span. |
minutes | Minutes value of the result time span. |
hours | Hours value of the result time span. |
|
inline |
Get days fraction of the time span, total 24 hour portions in the duration.
Time span could be negative, in which case the value will be negative too. There is no correspondent ToDays function, as days is the largest quantity of MTimeSpan.
|
virtual |
int MTimeSpan::GetHours | ( | ) | const |
Get hours part of the time span, -23 to 23.
int MTimeSpan::GetMinutes | ( | ) | const |
Get minutes fraction of the time span.
int MTimeSpan::GetSeconds | ( | ) | const |
Get seconds fraction of the time span.
MVariant MTimeSpan::Multiply | ( | int | numberOfTimes | ) | const |
Multiply a time span object with the given number of times, return the result.
MVariant MTimeSpan::NewClone | ( | ) | const |
Reflection-enabling copy constructor.
|
inline |
Inequality comparison operator.
|
inline |
Assignment with multiplication operator.
Add operator.
Assignment with addition operator.
Subtraction operator.
Assignment with subtraction operator.
MTimeSpan MTimeSpan::operator/ | ( | int | numberOfTimes | ) | const |
Division operator.
|
inline |
Assignment with division operator.
|
inline |
Less-than operator.
|
inline |
Less than or equal to operator.
Assignment operator.
|
inline |
Equality comparison operator.
|
inline |
Greater-than operator.
|
inline |
Greater than or equal to operator.
|
inline |
Set all parameters for the time span.
Beware that the order of parameters is reverse to one usually assumed. Negative values indicate negative time span (into the past).
Also, no check is done for overflow condition (when number of days is so big that it does not fit in 67 years range supported by this class).
void MTimeSpan::SetAsString | ( | const MStdString & | ) |
Represent time span as string.
Zero time span is represented as "00:00:00". If the string fits in one day, the property will have only hours, minutes and seconds, such as "00:00:01" (one second into the future), "23:00:00" (23 hours into the future). Otherwise, if the time is bigger than one day it will have number of days at the beginning, separated by a blank, such as "1000 00:00:00" for 1000 days into the future. Negative time span (referring to the past) will have a minus sign at the beginning, such as "-00:01:00" for one minute into the past, and "-100 00:00:00" for 100 days into the past.
The given time span string syntax is this:
Examples of valid string inputs:
Subtract an object to time span object and return the result, reflection-enabling service.
|
inline |
Convert time span to hours.
This function differs from GetHours in that it returns the total value.
|
inline |
Convert time span to minutes.
This function differs from GetMinutes in that it returns the total value.
|
inline |
Convert time span to seconds.
This function differs from GetSeconds in that it returns the total value.
Add a time span to time value, and without changing the two return the result.
Add a time span to time value, and without changing the two return the result.
Add time span to this time and assign the result back to time.
Subtract a time span from time value, and without changing the two return the result.
Subtract one time value from another and return the resultant time span.