Server
API Reference Guide
Product Documentation:

Visualization Server
Documentation Home
List of all members | Public Member Functions | Static Public Member Functions

This class allows dates and times to be exchanged between processes. More...

#include <ilserver/datetime.h>

Inheritance diagram for MvDateTime:
IlsMvUserType

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...
 
MvDateTimeoperator+= (const MvDateTime &v)
 Addition and assignment operator. More...
 
MvDateTime operator- (const MvDateTime &v) const
 Subtraction operator. More...
 
MvDateTimeoperator-= (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...
 
MvDateTimeoperator= (const MvDateTime &time)
 Assignment operator taking an MvDateTime.
 
MvDateTimeoperator= (struct tm &time)
 Assignment operator taking a struct tm value. More...
 
MvDateTimeoperator= (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 IlsLogfileprint (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 IlsMvUserTypeasValue (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 IlsMvMessageilsEncode (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 MvDateTimeGetInvalidDate ()
 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 IlsMvUserTypeIlsDecode (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.
 

Detailed Description

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

See also
IlsMvDateTime.

Constructor & Destructor Documentation

◆ MvDateTime() [1/5]

MvDateTime::MvDateTime ( const struct tm &  time,
unsigned int  usec = 0 
)

Constructor that takes struct tm.

Parameters
timedate and time expressed as tm struct.
usec(optional) number of milliseconds, defaults to 0

◆ MvDateTime() [2/5]

MvDateTime::MvDateTime ( time_t  time,
unsigned int  usec = 0 
)

Constructor that takes time_t value.

Parameters
timedate and time expressed as time_t value.
usec(optional) number of milliseconds, defaults to 0

◆ MvDateTime() [3/5]

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.

Parameters
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() [4/5]

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.

Parameters
yearyear using four digits (e.g. 2001)
monmonth, from 1 to 12
dayday 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() [5/5]

MvDateTime::MvDateTime ( IlsString  timeString)

Constructor that takes a string.

Supported formats are:

  • mm/dd/yyyy hh:mm:ss mmm
  • YYYYMMDDHHMM
  • YYYYMMDDHHMMSS
  • YYYYMMDDHHMMSSMMM
  • HHMMSS
Parameters
timeStringa string containing the time

Member Function Documentation

◆ asGMTString()

virtual IlsString MvDateTime::asGMTString ( IlsString  defaultVal = "<invalid>",
IlsString  format = (const char *) 0 
) const
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.

◆ asLong()

virtual long MvDateTime::asLong ( long  defaultVal = -1) const
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.

◆ asSourceString()

virtual IlsString MvDateTime::asSourceString ( IlsString  defaultVal = "<invalid>",
IlsString  format = (const char *) 0 
) const
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.

◆ asString()

virtual IlsString MvDateTime::asString ( IlsString  defaultVal = "<invalid>") const
virtual

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.

◆ getDay()

int MvDateTime::getDay ( ) const

Returns the day in a two-digit format (1-31).

Returns
the day, or -1 if the date is invalid

◆ getDayLightSavings()

int MvDateTime::getDayLightSavings ( ) const

Returns 1 if in Daylight Savings time, 0 otherwise.

Returns
-1 if the date is invalid, or if the DST status is unknown.

◆ GetDefaultDateTimeFormat()

static IlsString MvDateTime::GetDefaultDateTimeFormat ( )
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"

◆ GetDefaultTimeFormat()

static IlsString MvDateTime::GetDefaultTimeFormat ( )
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"

◆ getHour()

int MvDateTime::getHour ( ) const

Return the hour in a two-digit format (0-23).

Returns
the hour, or -1 if the date is invalid

◆ getMin()

int MvDateTime::getMin ( ) const

Returns the minutes in a two-digit format (0-59).

Returns
the minutes, or -1 if the date is invalid

◆ getMon()

int MvDateTime::getMon ( ) const

Returns the month in a two-digit format (1-12).

Returns
the month, or -1 if the date is invalid

◆ getSec()

int MvDateTime::getSec ( ) const

Returns the seconds in a two-digit format (0-59).

Returns
the seconds, or -1 if the date is invalid

◆ getSourceTimezone()

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.

Returns
-1 if the date is invalid.

◆ getUSec()

int MvDateTime::getUSec ( ) const

Returns the milliseconds.

Returns
the milliseconds, or -1 if the date is invalid

◆ getYear()

int MvDateTime::getYear ( ) const

Returns the year represented in a four-digit format.

Returns
the year, or -1 if the date is invalid

◆ isTime()

IlsBoolean MvDateTime::isTime ( ) const

Indicates whether this object stores only a time, or also a date.

Returns
IlsTrue if this object is valid and stores only a time.

◆ operator!=() [1/2]

virtual IlsBoolean MvDateTime::operator!= ( const IlsMvUserType v) const
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.

◆ operator!=() [2/2]

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.

Parameters
va date/time object to compare to
Returns
true if the current object is not equal to v

◆ operator+()

MvDateTime MvDateTime::operator+ ( const MvDateTime v) const

Addition operator.

Parameters
va date/time object to add to the current object
Returns
a date/time object representing the sum of this object and the v parameter

◆ operator+=()

MvDateTime& MvDateTime::operator+= ( const MvDateTime v)

Addition and assignment operator.

Parameters
va date/time object to add to the current object
Returns
the current object representing the sum of this object and the v parameter

◆ operator-()

MvDateTime MvDateTime::operator- ( const MvDateTime v) const

Subtraction operator.

Parameters
va date/time object to subtract from the current object
Returns
a date/time object representing the difference between this object and the v parameter

◆ operator-=()

MvDateTime& MvDateTime::operator-= ( const MvDateTime v)

Subtraction and assignment operator.

Parameters
va date/time object to subtract from the current object
Returns
the current object representing the difference between this object and the v parameter

◆ operator<() [1/2]

virtual IlsBoolean MvDateTime::operator< ( const IlsMvUserType ) const
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.

◆ operator<() [2/2]

IlsBoolean MvDateTime::operator< ( const MvDateTime v) const

Less than operator.

Note that the result of comparing invalid date/times is not defined.

Parameters
va date/time object to compare to
Returns
true if the current object is earlier than v

◆ operator<=() [1/2]

virtual IlsBoolean MvDateTime::operator<= ( const IlsMvUserType ) const
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.

◆ operator<=() [2/2]

IlsBoolean MvDateTime::operator<= ( const MvDateTime v) const

Less than or equal operator.

Note that the result of comparing invalid date/times is not defined.

Parameters
va date/time object to compare to
Returns
true if the current object is earlier than or equal to v

◆ operator=() [1/2]

MvDateTime& MvDateTime::operator= ( struct tm &  time)

Assignment operator taking a struct tm value.

Returns
a reference to the current object.

◆ operator=() [2/2]

MvDateTime& MvDateTime::operator= ( time_t  time)

Assignment operator taking a time_t value.

Returns
a reference to the current object.

◆ operator==() [1/2]

virtual IlsBoolean MvDateTime::operator== ( const IlsMvUserType v) const
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.

◆ operator==() [2/2]

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.

Parameters
vvalue to compare to.
Returns
true if the current object is equal to v

◆ operator>() [1/2]

virtual IlsBoolean MvDateTime::operator> ( const IlsMvUserType ) const
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.

◆ operator>() [2/2]

IlsBoolean MvDateTime::operator> ( const MvDateTime v) const

Greater than operator.

Note that the result of comparing invalid date/times is not defined.

Parameters
va date/time object to compare to
Returns
true if the current object is later than v

◆ operator>=() [1/2]

virtual IlsBoolean MvDateTime::operator>= ( const IlsMvUserType ) const
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.

◆ operator>=() [2/2]

IlsBoolean MvDateTime::operator>= ( const MvDateTime v) const

Greater than or equal operator.

Note that the result of comparing invalid date/times is not defined.

Parameters
va date/time object to compare to
Returns
true if the current object is later than or equal to v

◆ print()

virtual IlsLogfile& MvDateTime::print ( IlsLogfile ) const
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.

◆ setDateTime() [1/2]

IlsBoolean MvDateTime::setDateTime ( const struct tm &  time,
unsigned int  usec = 0 
)

Sets the date and time from a struct tm value.

Parameters
timedate and time expressed as struct tm value.
usec(optional) number of milliseconds, defaults to 0
Returns
IlsTrue if successful.

◆ setDateTime() [2/2]

IlsBoolean MvDateTime::setDateTime ( time_t  time,
unsigned int  usec = 0 
)

Sets the date and time from a time_t value.

Parameters
timedate and time expressed as time_t value.
usec(optional) number of milliseconds, defaults to 0
Returns
IlsTrue if successful.

◆ setDay()

IlsBoolean MvDateTime::setDay ( unsigned int  day)

Sets the day.

Parameters
dayvalid range is from 1 to 31 (or less, depending on the month and year).
Returns
IlsTrue if successful.

◆ SetDefaultDateTimeFormat()

static void MvDateTime::SetDefaultDateTimeFormat ( IlsString  format)
static

Modifies the default format used to convert dates to strings.

It should be provided in the format understood by the strftime() system function.

◆ SetDefaultTimeFormat()

static void MvDateTime::SetDefaultTimeFormat ( IlsString  format)
static

Modifies the default format used to convert times to strings.

It should be provided in the format understood by the strftime() system function.

◆ setHour()

IlsBoolean MvDateTime::setHour ( unsigned int  hour)

Sets the hour.

Parameters
hourvalid range is from 0 to 23.
Returns
IlsTrue if successful.

◆ setIsdst()

IlsBoolean MvDateTime::setIsdst ( int  isdst)

Sets the Daylight Savings time flag.

Parameters
isdstDST is on if isdst > 0, off if == 0, unknown if < 0.
Returns
IlsTrue if successful.

◆ setMin()

IlsBoolean MvDateTime::setMin ( unsigned int  minute)

Sets the minutes.

Parameters
minutevalid range is from 0 to 59.
Returns
IlsTrue if successful.

◆ setMon()

IlsBoolean MvDateTime::setMon ( unsigned int  month)

Sets the month.

Parameters
monthvalid range is from 1 to 12.
Returns
IlsTrue if successful.

◆ setSec()

IlsBoolean MvDateTime::setSec ( unsigned int  second)

Sets the seconds.

Parameters
secondvalid range is from 0 to 59.
Returns
IlsTrue if successful.

◆ setTime()

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.

Parameters
timetime expressed as time_t value.
usec(optional) number of milliseconds, defaults to 0
Returns
IlsTrue if successful.

◆ setUSec()

IlsBoolean MvDateTime::setUSec ( unsigned int  usecs)

Sets the milliseconds.

Parameters
usecsvalid range is from 0 to 999.
Returns
IlsTrue if successful.

◆ setYear()

IlsBoolean MvDateTime::setYear ( unsigned int  year)

Sets the year.

Parameters
yearvalid range is from 1900 to 2040.
Returns
IlsTrue if successful.