This class allows dates and times to be exchanged between processes. More...
#include <ilserver/datetime.h>
Public Member Functions | |
MvDateTime () | |
Constructor that creates an instance set to the current local date and time. | |
MvDateTime (const MvDateTime &time) | |
Copy constructor. | |
MvDateTime (const struct tm &time, unsigned int usec=0) | |
Constructor that takes struct tm . More... | |
MvDateTime (IlsString timeString) | |
Constructor that takes a string. More... | |
MvDateTime (time_t time, unsigned int usec=0) | |
Constructor that takes time_t value. More... | |
MvDateTime (unsigned int hour, unsigned int min, unsigned int sec, unsigned int usec=0) | |
Constructor that takes explicit values for all time components. It builds a pure time object, the date is not set. More... | |
MvDateTime (unsigned int year, unsigned int mon, unsigned int day, unsigned int hour, unsigned int min, unsigned int sec, unsigned int usec=0, int isdst=-1) | |
Constructor that takes explicit values for all date and time components. More... | |
~MvDateTime () | |
Destructor. | |
virtual IlsString | asGMTString (IlsString defaultVal="<invalid>", IlsString format=(const char *) 0) const |
Returns a string representation of the date and time in GMT. More... | |
virtual long | asLong (long defaultVal=-1) const |
Returns the date as a number of seconds since 1-1-1970. More... | |
virtual IlsString | asSourceString (IlsString defaultVal="<invalid>", IlsString format=(const char *) 0) const |
Returns a string representation of the date and time in the source timezone. More... | |
virtual IlsString | asString (IlsString defaultVal="<invalid>") const |
Returns a string representation of the date and time in the local timezone. More... | |
int | getDay () const |
Returns the day in a two-digit format (1-31). More... | |
int | getDayLightSavings () const |
Returns 1 if in Daylight Savings time, 0 otherwise. More... | |
int | getHour () const |
Return the hour in a two-digit format (0-23). More... | |
int | getMin () const |
Returns the minutes in a two-digit format (0-59). More... | |
int | getMon () const |
Returns the month in a two-digit format (1-12). More... | |
int | getSec () const |
Returns the seconds in a two-digit format (0-59). More... | |
int | getSourceTimezone () const |
Returns the offset from GMT for the source timezone The offset is measured in seconds, and positive numbers are timezones west of GMT. More... | |
int | getUSec () const |
Returns the milliseconds. More... | |
int | getYear () const |
Returns the year represented in a four-digit format. More... | |
IlsBoolean | isLeapYear () const |
Returns IlsTrue if the date falls in a leap year. | |
IlsBoolean | isTime () const |
Indicates whether this object stores only a time, or also a date. More... | |
IlsBoolean | isValid () const |
Returns IlsTrue if the date is valid. | |
void | markTime () |
Set the current local time. | |
virtual IlsBoolean | operator!= (const IlsMvUserType &v) const |
Called by the operator IlsMvValue::operator!=() when the object and the argument to which it applies contain user-defined type values. More... | |
IlsBoolean | operator!= (const MvDateTime &v) const |
Not equal operator. More... | |
MvDateTime | operator+ (const MvDateTime &v) const |
Addition operator. More... | |
MvDateTime & | operator+= (const MvDateTime &v) |
Addition and assignment operator. More... | |
MvDateTime | operator- (const MvDateTime &v) const |
Subtraction operator. More... | |
MvDateTime & | operator-= (const MvDateTime &v) |
Subtraction and assignment operator. More... | |
virtual IlsBoolean | operator< (const IlsMvUserType &userType) const |
Called by the operator IlsMvValue::operator<() when the object and the argument to which it applies contain user-defined type values. More... | |
IlsBoolean | operator< (const MvDateTime &v) const |
Less than operator. More... | |
virtual IlsBoolean | operator<= (const IlsMvUserType &v) const |
Called by the operator IlsMvValue::operator<=() when the object and the argument to which it applies contain user-defined type values. More... | |
IlsBoolean | operator<= (const MvDateTime &v) const |
Less than or equal operator. More... | |
MvDateTime & | operator= (const MvDateTime &time) |
Assignment operator taking an MvDateTime . | |
MvDateTime & | operator= (struct tm &time) |
Assignment operator taking a struct tm value. More... | |
MvDateTime & | operator= (time_t time) |
Assignment operator taking a time_t value. More... | |
virtual IlsBoolean | operator== (const IlsMvUserType &v) const |
Called by the operator IlsMvValue::operator==() when the object and the argument to which it applies contain user-defined type values. More... | |
IlsBoolean | operator== (const MvDateTime &v) const |
Comparison operator. More... | |
virtual IlsBoolean | operator> (const IlsMvUserType &userType) const |
Called by the operator IlsMvValue::operator>() when the object and the argument to which it applies contain user-defined type values. More... | |
IlsBoolean | operator> (const MvDateTime &v) const |
Greater than operator. More... | |
virtual IlsBoolean | operator>= (const IlsMvUserType &v) const |
Called by the operator IlsMvValue::operator>=() when the object and the argument to which it applies contain user-defined type values. More... | |
IlsBoolean | operator>= (const MvDateTime &v) const |
Greater than or equal operator. More... | |
virtual IlsLogfile & | print (IlsLogfile &lf) const |
Called in trace mode to display a value whose type is user-defined. More... | |
IlsBoolean | setDateTime (const struct tm &time, unsigned int usec=0) |
Sets the date and time from a struct tm value. More... | |
IlsBoolean | setDateTime (time_t time, unsigned int usec=0) |
Sets the date and time from a time_t value. More... | |
IlsBoolean | setDay (unsigned int day) |
Sets the day. More... | |
IlsBoolean | setHour (unsigned int hour) |
Sets the hour. More... | |
IlsBoolean | setIsdst (int isdst) |
Sets the Daylight Savings time flag. More... | |
IlsBoolean | setMin (unsigned int minute) |
Sets the minutes. More... | |
IlsBoolean | setMon (unsigned int month) |
Sets the month. More... | |
IlsBoolean | setSec (unsigned int second) |
Sets the seconds. More... | |
IlsBoolean | setTime (time_t time, unsigned int usec=0) |
Sets the time from a time_t value. More... | |
IlsBoolean | setUSec (unsigned int usecs) |
Sets the milliseconds. More... | |
IlsBoolean | setYear (unsigned int year) |
Sets the year. More... | |
Public Member Functions inherited from IlsMvUserType | |
virtual | ~IlsMvUserType () |
Virtual destructor. | |
virtual IlsBoolean | asBoolean (IlsBoolean defaultVal=IlsFalse) const |
Called by IlsMvValue::asBoolean() when the instance of IlsMvValue to which it applies contains an object whose type is user-defined. More... | |
virtual char | asChar (char defaultVal=0) const |
Called by IlsMvValue::asChar() when the object of type IlsMvValue to which it applies contains an object whose type is user-defined. More... | |
virtual float | asFloat (float defaultVal=0.0) const |
Called by IlsMvValue::asFloat() when the object of type IlsMvValue to which it applies contains an object whose type is user-defined. More... | |
virtual double | asDouble (double defaultVal=0.0) const |
Called by IlsMvValue::asDouble() when the object of type IlsMvValue to which it applies contains an object whose type is user-defined. More... | |
virtual IlsMvRef | asObjectRef (IlsMvRef defaultVal=IlsMvRef()) const |
Called by IlsMvValue::asObjectRef() when the object of type IlsMvValue to which it applies contains an object whose type is user-defined. More... | |
virtual IlsMvUserType * | asValue (IlsMvDataType typeId, IlsMvUserType *defaultVal=0) const |
Called by Rogue Wave Server when it needs to convert a user type value into another user type. More... | |
virtual IlsBoolean | operator! () const |
Called by the operator IlsMvValue::operator!() when the object and the argument to which it applies contain user-defined type values. More... | |
virtual IlsMvMessage & | ilsEncode (IlsMvMessage &) const =0 |
This pure virtual member function is called to encode a value whose type is user-defined in an instance of IlsMvMessage . More... | |
Static Public Member Functions | |
static IlsString | GetDefaultDateTimeFormat () |
Returns the default format used to convert dates to strings. More... | |
static IlsString | GetDefaultTimeFormat () |
Returns the default format used to convert times to strings. More... | |
static const MvDateTime & | GetInvalidDate () |
Returns an invalid date and time. | |
static void | SetDefaultDateTimeFormat (IlsString format) |
Modifies the default format used to convert dates to strings. More... | |
static void | SetDefaultTimeFormat (IlsString format) |
Modifies the default format used to convert times to strings. More... | |
Static Public Member Functions inherited from IlsMvUserType | |
static IlsMvUserType * | IlsDecode (IlsMvMessage &) |
This static member function is called by Server to extract a user-type value from a message. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from IlsMvUserType | |
IlsMvUserType () | |
The default constructor of the class is protected. | |
This class allows dates and times to be exchanged between processes.
Library: mvserver
and mvcomp
As a user type, IlsMvDateTime is available under the name MvDateTime to be compliant with the Java API naming conventions
IlsMvDateTime
. MvDateTime::MvDateTime | ( | const struct tm & | time, |
unsigned int | usec = 0 |
||
) |
Constructor that takes struct tm
.
time | date and time expressed as tm struct. |
usec | (optional) number of milliseconds, defaults to 0 |
MvDateTime::MvDateTime | ( | time_t | time, |
unsigned int | usec = 0 |
||
) |
Constructor that takes time_t
value.
time | date and time expressed as time_t value. |
usec | (optional) number of milliseconds, defaults to 0 |
MvDateTime::MvDateTime | ( | unsigned int | hour, |
unsigned int | min, | ||
unsigned int | sec, | ||
unsigned int | usec = 0 |
||
) |
Constructor that takes explicit values for all time components. It builds a pure time object, the date is not set.
hour | (optional) hour, from 0 to 23, defaults to 0 |
min | (optional) minute, from 0 to 59, defaults to 0 |
sec | (optional) second, from 0 to 59, defaults to 0 |
usec | (optional) number of milliseconds, defaults to 0 |
MvDateTime::MvDateTime | ( | unsigned int | year, |
unsigned int | mon, | ||
unsigned int | day, | ||
unsigned int | hour, | ||
unsigned int | min, | ||
unsigned int | sec, | ||
unsigned int | usec = 0 , |
||
int | isdst = -1 |
||
) |
Constructor that takes explicit values for all date and time components.
year | year using four digits (e.g. 2001) |
mon | month, from 1 to 12 |
day | day of the month, from 1 to 31 (or less depending on the month) |
hour | (optional) hour, from 0 to 23, defaults to 0 |
min | (optional) minute, from 0 to 59, defaults to 0 |
sec | (optional) second, from 0 to 59, defaults to 0 |
usec | (optional) number of milliseconds, defaults to 0 |
isdst | (optional) daylight saving time set to on if >0 , off if == 0, unknown if < 0. Defaults to -1 |
MvDateTime::MvDateTime | ( | IlsString | timeString | ) |
Constructor that takes a string.
Supported formats are:
mm/dd/yyyy hh:mm:ss mmm
YYYYMMDDHHMM
YYYYMMDDHHMMSS
YYYYMMDDHHMMSSMMM
HHMMSS
timeString | a string containing the time |
|
virtual |
Returns a string representation of the date and time in GMT.
If the instance is not valid, the string passed in defaultVal is returned.
|
virtual |
Returns the date as a number of seconds since 1-1-1970.
When the instance is not valid, the value passed in defaultVal is returned.
Reimplemented from IlsMvUserType.
|
virtual |
Returns a string representation of the date and time in the source timezone.
The date is formatted for the timezone of the process that created the original object. When the instance is not valid, the string passed in defaultVal is returned.
Returns a string representation of the date and time in the local timezone.
The date is formatted for the local timezone of the process. When the instance is not valid, the string passed in defaultVal is returned.
Reimplemented from IlsMvUserType.
int MvDateTime::getDay | ( | ) | const |
Returns the day in a two-digit format (1-31).
-1
if the date is invalid int MvDateTime::getDayLightSavings | ( | ) | const |
Returns 1
if in Daylight Savings time, 0
otherwise.
-1
if the date is invalid, or if the DST status is unknown.
|
static |
Returns the default format used to convert dates to strings.
It is provided in the format understood by the strftime()
system function. The default is "%x - %H:%M:%S"
|
static |
Returns the default format used to convert times to strings.
It is provided in the format understood by the strftime()
system function. The default is "%H:%M:%S"
int MvDateTime::getHour | ( | ) | const |
Return the hour in a two-digit format (0-23).
-1
if the date is invalid int MvDateTime::getMin | ( | ) | const |
Returns the minutes in a two-digit format (0-59).
-1
if the date is invalid int MvDateTime::getMon | ( | ) | const |
Returns the month in a two-digit format (1-12).
-1
if the date is invalid int MvDateTime::getSec | ( | ) | const |
Returns the seconds in a two-digit format (0-59).
-1
if the date is invalid int MvDateTime::getSourceTimezone | ( | ) | const |
Returns the offset from GMT for the source timezone The offset is measured in seconds, and positive numbers are timezones west of GMT.
-1
if the date is invalid. int MvDateTime::getUSec | ( | ) | const |
Returns the milliseconds.
-1
if the date is invalid int MvDateTime::getYear | ( | ) | const |
Returns the year represented in a four-digit format.
-1
if the date is invalid IlsBoolean MvDateTime::isTime | ( | ) | const |
Indicates whether this object stores only a time, or also a date.
|
virtual |
Called by the operator IlsMvValue::operator!=()
when the object and the argument to which it applies contain user-defined type values.
It returns IlsTrue
and can be overridden.
Reimplemented from IlsMvUserType.
IlsBoolean MvDateTime::operator!= | ( | const MvDateTime & | v | ) | const |
Not equal operator.
Note that dates are compared on their GMT value, i.e. they are considered equal even if they have a different source timezone.
v | a date/time object to compare to |
MvDateTime MvDateTime::operator+ | ( | const MvDateTime & | v | ) | const |
Addition operator.
v | a date/time object to add to the current object |
MvDateTime& MvDateTime::operator+= | ( | const MvDateTime & | v | ) |
Addition and assignment operator.
v | a date/time object to add to the current object |
MvDateTime MvDateTime::operator- | ( | const MvDateTime & | v | ) | const |
Subtraction operator.
v | a date/time object to subtract from the current object |
MvDateTime& MvDateTime::operator-= | ( | const MvDateTime & | v | ) |
Subtraction and assignment operator.
v | a date/time object to subtract from the current object |
|
virtual |
Called by the operator IlsMvValue::operator<()
when the object and the argument to which it applies contain user-defined type values.
It returns IlsFalse
and can be overridden.
Reimplemented from IlsMvUserType.
IlsBoolean MvDateTime::operator< | ( | const MvDateTime & | v | ) | const |
Less than operator.
Note that the result of comparing invalid date/times is not defined.
v | a date/time object to compare to |
|
virtual |
Called by the operator IlsMvValue::operator<=()
when the object and the argument to which it applies contain user-defined type values.
It returns IlsFalse
and can be overridden.
Reimplemented from IlsMvUserType.
IlsBoolean MvDateTime::operator<= | ( | const MvDateTime & | v | ) | const |
Less than or equal operator.
Note that the result of comparing invalid date/times is not defined.
v | a date/time object to compare to |
MvDateTime& MvDateTime::operator= | ( | struct tm & | time | ) |
Assignment operator taking a struct tm
value.
MvDateTime& MvDateTime::operator= | ( | time_t | time | ) |
Assignment operator taking a time_t
value.
|
virtual |
Called by the operator IlsMvValue::operator==()
when the object and the argument to which it applies contain user-defined type values.
It returns IlsFalse
and can be overridden.
Reimplemented from IlsMvUserType.
IlsBoolean MvDateTime::operator== | ( | const MvDateTime & | v | ) | const |
Comparison operator.
Note that dates are compared on their GMT value, i.e. they are considered equal even if they have a different source timezone.
v | value to compare to. |
|
virtual |
Called by the operator IlsMvValue::operator>()
when the object and the argument to which it applies contain user-defined type values.
It returns IlsFalse
and can be overridden.
Reimplemented from IlsMvUserType.
IlsBoolean MvDateTime::operator> | ( | const MvDateTime & | v | ) | const |
Greater than operator.
Note that the result of comparing invalid date/times is not defined.
v | a date/time object to compare to |
|
virtual |
Called by the operator IlsMvValue::operator>=()
when the object and the argument to which it applies contain user-defined type values.
It returns IlsFalse
and can be overridden.
Reimplemented from IlsMvUserType.
IlsBoolean MvDateTime::operator>= | ( | const MvDateTime & | v | ) | const |
Greater than or equal operator.
Note that the result of comparing invalid date/times is not defined.
v | a date/time object to compare to |
|
virtual |
Called in trace mode to display a value whose type is user-defined.
It as no effect but can be overridden.
Reimplemented from IlsMvUserType.
IlsBoolean MvDateTime::setDateTime | ( | const struct tm & | time, |
unsigned int | usec = 0 |
||
) |
Sets the date and time from a struct tm
value.
time | date and time expressed as struct tm value. |
usec | (optional) number of milliseconds, defaults to 0 |
IlsBoolean MvDateTime::setDateTime | ( | time_t | time, |
unsigned int | usec = 0 |
||
) |
Sets the date and time from a time_t
value.
time | date and time expressed as time_t value. |
usec | (optional) number of milliseconds, defaults to 0 |
IlsBoolean MvDateTime::setDay | ( | unsigned int | day | ) |
Sets the day.
day | valid range is from 1 to 31 (or less, depending on the month and year). |
|
static |
Modifies the default format used to convert dates to strings.
It should be provided in the format understood by the strftime()
system function.
|
static |
Modifies the default format used to convert times to strings.
It should be provided in the format understood by the strftime()
system function.
IlsBoolean MvDateTime::setHour | ( | unsigned int | hour | ) |
Sets the hour.
hour | valid range is from 0 to 23. |
IlsBoolean MvDateTime::setIsdst | ( | int | isdst | ) |
Sets the Daylight Savings time flag.
isdst | DST is on if isdst > 0, off if == 0, unknown if < 0. |
IlsBoolean MvDateTime::setMin | ( | unsigned int | minute | ) |
Sets the minutes.
minute | valid range is from 0 to 59. |
IlsBoolean MvDateTime::setMon | ( | unsigned int | month | ) |
Sets the month.
month | valid range is from 1 to 12. |
IlsBoolean MvDateTime::setSec | ( | unsigned int | second | ) |
Sets the seconds.
second | valid range is from 0 to 59. |
IlsBoolean MvDateTime::setTime | ( | time_t | time, |
unsigned int | usec = 0 |
||
) |
Sets the time from a time_t
value.
This constructs a pure time object, the date is not set.
time | time expressed as time_t value. |
usec | (optional) number of milliseconds, defaults to 0 |
IlsBoolean MvDateTime::setUSec | ( | unsigned int | usecs | ) |
Sets the milliseconds.
usecs | valid range is from 0 to 999. |
IlsBoolean MvDateTime::setYear | ( | unsigned int | year | ) |
Sets the year.
year | valid range is from 1900 to 2040. |