IlsMvDateTime
 
IlsMvDateTime
Category 
Dynamic view-related class
Inheritance Path 
IlsMvUserType
IlsMvDateTime
Description 
This class enables dates and times to be exchanged between server and components. As a user type, this type is also available under the name MvDateTime to be compliant with the JavaTM API naming conventions.
Libraries 
<mvserver> and <mvcomp>
Header File 
#include <ilserver/datetime.h>
Synopsis 
class IlsMvKeyValueTable: public IlsMvArray {
public:
 
IlsMvDateTime();
IlsMvDateTime(const struct tm& time, unsigned int usec=0);
IlsMvDateTime(time_t time, unsigned int usec=0);
IlsMvDateTime(unsigned int hour,
unsigned int min,
unsigned int sec,
unsigned int usec=0);
IlsMvDateTime(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);
IlsMvDateTime(IlsString timeString);
IlsMvDateTime(const MvDateTime& time);
 
IlsMvDateTime& operator = (const MvDateTime& time);
IlsMvDateTime& operator = (time_t time);
IlsMvDateTime& operator = (struct tm& time);
IlsBoolean operator == (const MvDateTime& v) const;
IlsBoolean operator != (const MvDateTime& v) const;
IlsBoolean operator < (const MvDateTime& v) const;
IlsBoolean operator > (const MvDateTime& v) const;
IlsBoolean operator <= (const MvDateTime& v) const;
IlsBoolean operator >= (const MvDateTime& v) const;
IlsMvDateTime operator - (const MvDateTime& v) const;
IlsMvDateTime operator + (const MvDateTime& v) const;
IlsMvDateTime& operator -= (const MvDateTime& v);
IlsMvDateTime& operator += (const MvDateTime& v);
Accessors
IlsBoolean isTime()const;
int getYear() const;
int getMon() const;
int getDay() const;
int getHour() const;
int getMin() const;
int getSec() const;
int getUSec() const;
int getDayLightSavings() const;
IlsBoolean isLeapYear() const;
int getSourceTimezone() const;
IlsBoolean isValid() const;
static const MvDateTime& GetInvalidDate();
Modifiers
IlsBoolean setDateTime(time_t time, unsigned int usec=0);
IlsBoolean setDateTime(const struct tm& time,
unsigned int usec=0);
IlsBoolean setTime(time_t time, unsigned int usec=0);
IlsBoolean setYear(unsigned int year);
IlsBoolean setMon(unsigned int month);
IlsBoolean setDay(unsigned int day );
IlsBoolean setHour(unsigned int hour);
IlsBoolean setMin(unsigned int minute);
IlsBoolean setSec(unsigned int second);
IlsBoolean setUSec(unsigned int usecs);
IlsBoolean setIsdst(int isdst);
void markTime();
Conversion
virtual IlsString asString(IlsString defaultVal="<invalid>")
const;
virtual IlsString asSourceString
(IlsString defaultVal="<invalid>",
IlsString format= (const char*)0) const;
virtual IlsString asGMTString
(IlsString defaultVal="<invalid>",
IlsString format=(const char*)0) const;
virtual long asLong(long defaultVal=-1) const;
Date and Time Format
static IlsString GetDefaultDateTimeFormat();
static void SetDefaultDateTimeFormat(IlsString format);
static IlsString GetDefaultTimeFormat();
static void SetDefaultTimeFormat(IlsString format);
};
Constructors 
IlsMvDateTime();
This constructor creates an IlsMvDateTime instance set to the current local date and time.
IlsMvDateTime(const struct tm& time, unsigned int usec=0);
This constructor takes a struct tm as its first parameter. The time parameter is the date and time expressed as a tm struct. The usec optional parameter is the number of milliseconds. It defaults to 0.
IlsMvDateTime(time_t time, unsigned int usec=0);
This constructor takes a time_t value as its first parameter. The time parameter is the date and time expressed as a time_t value. The usec optional parameter is the number of milliseconds. It defaults to 0.
IlsMvDateTime(unsigned int hour,
unsigned int min,
unsigned int sec,
unsigned int usec=0);
This constructor creates a date-and-time instance that takes explicit values for all the time parameters. Each of these parameters is optional. It builds a pure time object because the date is not set.
*hour: the hour, from 0 to 23. The default value is 0.
*min: the number of minutes, from 0 to 59. The default value is 0.
*sec: the number of seconds, from 0 to 59. The default value is 0.
*usec: the number of milliseconds. The default value is 0.
IlsMvDateTime(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);
This constructor creates a date-and-time instance that takes explicit values for all the date and time elements.
*year: the year expressed with four digits (for example: 2001).
*mon: the month of the year, from 1 to 12.
*day: the day of the month, from 1 to 31 (or less depending on the month).
*hour: the hour, from 0 to 23. The default value is 0.
*min: the number of minutes, from 0 to 59. The default value is 0.
*sec: the number of seconds, from 0 to 59. The default value is 0.
*usec: the number of milliseconds. The default value is 0.
*isdst: This optional parameter is the daylight saving time. It is set “on” if its value is greater than 0, off if its value is 0, or unknown if the value is less than 0. The default value is -1.
IlsMvDateTime(IlsString timeString);
This constructor creates a date-and-time instance as a string. The supported formats are:
*mm/dd/yyyy hh:mm:ss mmm
*YYYYMMDDHHMM
*YYYYMMDDHHMMSS
*YYYYMMDDHHMMSSMMM
*HHMMSS
The timeString parameter is a string containing the time.
IlsMvDateTime(const MvDateTime& time);
This is a copy constructor.
Operators 
IlsMvDateTime& operator = (const MvDateTime& time);
This assignment operator takes a refference to a MvDateTime instance as its parameter. It returns a reference to the current object.
IlsMvDateTime& operator = (time_t time);
This assignment operator takes a time_t value as its parameter. It returns a reference to the current object.
IlsMvDateTime& operator = (struct tm& time);
This assignment operator takes a struct tm value as its parameter. It returns a reference to the current object.
IlsBoolean operator == (const MvDateTime& v) const;
This comparison operator compares dates on their GMT value. In other words, two dates may be considered equal even if they have a different source time zone. Parameter v is the value against which the current date-and-time object is compared. This function returns IlsTrue if the current object is equal to v.
IlsBoolean operator != (const MvDateTime& v) const;
This comparison operator compares dates on their GMT value. In other words, two dates may be considered equal even if they have a different source time zone. Parameter v is the value against which the current date-and-time object is compared. This function returns IlsTrue if the current object is equal to v.
IlsBoolean operator < (const MvDateTime& v) const;
This comparison operator checks whether the current date-and-time object is earlier than v and returns IlsTrue if it is or IlsFalse if it is not. The result of comparing invalid date-and-time objects is not defined.
IlsBoolean operator > (const MvDateTime& v) const;
This comparison operator checks whether the current date-and-time object is later than v and returns IlsTrue if it is or IlsFalse if it is not. The result of comparing invalid date-and-time objects is not defined.
IlsBoolean operator <= (const MvDateTime& v) const;
This comparison operator checks whether the current date-and-time object is earlier than v or simultaneous, and returns IlsTrue if it is either earlier or simultaneous, or IlsFalse otherwise. The result of comparing invalid date-and-time objects is not defined.
IlsBoolean operator >= (const MvDateTime& v) const;
This comparison operator checks whether the current date-and-time object is later than v or simultaneous, and returns IlsTrue if it is either simultaneous or later, or IlsFalse otherwise. The result of comparing invalid date-and-time objects is not defined.
IlsMvDateTime operator - (const MvDateTime& v) const;
This operator substracts the date-and-time object specified as the v parameter from the current date-and-time object. This function returns a date-and-time object representing the difference between the current object and the v parameter.
IlsMvDateTime operator + (const MvDateTime& v) const;
This operator adds the date-and-time object specified as the v parameter to the current date-and-time object. This function returns a date-and-time object representing the sum of this object and the v parameter.
IlsMvDateTime& operator -= (const MvDateTime& v);
This substraction and assignment operator substracts the date-and-time object specified as the v parameter from the current date-and-time object. This function returns the current date-and-time object representing the difference between the current object and the v parameter.
IlsMvDateTime& operator += (const MvDateTime& v);
This addition and assignment operator adds the date-and-time object specified as the v parameter to the current date-and-time object. This function returns the current date-and-time object representing the sum of this object and the v parameter.
Member Functions 
Accessors
IlsBoolean isTime() const;
This member function indicates whether the current object stores only a time, or also a date. It returns IlsTrue if this object is valid and stores only a time.
int getYear() const;
This member function returns the year expressed in a four-digit format, or -1 if the date is invalid.
int getMon() const;
This member function returns the month in a two-digit format (01-12), or -1 if the date is invalid.
int getDay() const;
This member function returns the day in a two-digit format (01-31), or -1 if the date is invalid.
int getHour() const;
This member function returns the hour in a two-digit format (00-23), or -1 if the date is invalid.
int getMin() const;
This member function returns the minutes in a two-digit format (00-59), or -1 if the date is invalid.
int getSec() const;
This member function returns the seconds in a two-digit format (00-59), or -1 if the date is invalid.
int getUSec() const;
This member function returns the milliseconds, or -1 if the date is invalid.
int getDayLightSavings() const;
This member function returns 1 if the Daylight Savings Time option is on, 0 if that setting is off, -1 if the date is invalid, or if the option status is unknown.
IlsBoolean isLeapYear() const;
This member function returns IlsTrue if the date falls in a leap year.
int getSourceTimezone() const;
This menber function returns the offset from GMT for the source time zone. The offset is measured in seconds, and positive numbers are the time zones west of GMT. This function returns -1 if the date is invalid.
IlsBoolean isValid() const;
This member function returns IlsTrue if the date is valid.
[static] const MvDateTime& GetInvalidDate();
This static member function returns an invalid date and time.
Modifiers
IlsBoolean setDateTime(time_t time, unsigned int usec=0);
This member function sets the date and time from a time_t value. It takes the following parameters:
*time is the date and time expressed as a time_t value.
*usec (optional) is the number of milliseconds. Its default value is 0.
This function returns IlsFalse if the value of the time parameter is not greater than 0 or IlsTrue if it executes successfully.
IlsBoolean setDateTime(const struct tm& time, unsigned int usec=0);
This member function sets the date and time from a struct tm value. It takes the following parameters:
*time is the date and time expressed as a struct tm value.
*usec (optional) is the number of milliseconds. Its default value is 0.
This function returns IlsFalse if the struct yields an insconsistent date and time, or IlsTrue if it executes successfully.
IlsBoolean setTime(time_t time, unsigned int usec=0);
This member function sets the time from a time_t value. It constructs a pure time object, the date is not set. It takes the following parameters:
*time is the date and time expressed as a time_t value.
*usec (optional) is number of milliseconds. Its default value is 0.
This function returns IlsFalse if the value of the time parameter is not greater than 0, or IlsTrue if it executes successfully.
IlsBoolean setYear(unsigned int year);
This member function sets the year. The valid values of the year parameter range from 1900 to 2040. This function returns IlsFalse if the value of the year parameter is out of range, or IlsTrue if it executes successfully.
IlsBoolean setMon(unsigned int month);
This member function sets the month. The valid values of the month parameter range from 1 to 12. This function returns IlsFalse if the value of the month parameter is out of range, or IlsTrue if it executes successfully.
IlsBoolean setDay(unsigned int day );
This member function sets the day. The valid values of the day parameter range from 1 to 31 (or less, depending on the month and year). This function returns IlsFalse if the value of the day parameter is out of range, or IlsTrue if it executes successfully.
IlsBoolean setHour(unsigned int hour);
This member function sets the hour. The valid values of the hour parameter range from 0 to 23. This function returns IlsFalse if the value of the hour parameter is out of range, or IlsTrue if it executes successfully.
IlsBoolean setMin(unsigned int minute);
This member function sets the minutes. The valid values of the minute parameter range from 0 to 59. This function returns IlsFalse if the value of the minute parameter is out of range, or IlsTrue if it executes successfully.
IlsBoolean setSec(unsigned int second);
This member function sets the seconds. The valid values of the second parameter range from 0 to 59. This function returns IlsFalse if the value of the second parameter is out of range, or IlsTrue if it executes successfully.
IlsBoolean setUSec(unsigned int usecs);
This member function sets the milliseconds. The valid values of the usecs parameter range is from 0 to 999. This function returns IlsFalse if the value of the usecs parameter is out of range, or IlsTrue if it executes successfully.
IlsBoolean setIsdst(int isdst);
This member function sets the Daylight Savings time flag. The possible settings for this flag are the following:
*on if isdst is greater than 0,
*off if isdst equals 0,
*unknown if isdst is less than 0.
This function returns IlsTrue if it is executes successfully.
void markTime();
This member function sets the current local time.
Conversion
[virtual] IlsString asString(IlsString defaultVal="<invalid>") const;
This virtual member function returns a string representation of the date and time in the local time zone. The date is formatted for the local time zone of the process. When the instance is not valid, the string passed as the defaultVal parameter is returned.
[virtual] IlsString asSourceString(IlsString defaultVal="<invalid>",
IlsString format=(const char*)0) const;
This virtual member function returns a string representation of the date and time in the source time zone. The date is formatted for the timezone of the process that created the original object. When the instance is not valid, the string passed as the defaultVal parameter is returned.
[virtual] IlsString asGMTString(IlsString defaultVal="<invalid>",
IlsString format=(const char*)0) const;
This virtual member function returns a string representation of the date and time in GMT. When the instance is not valid, the string passed as the defaultVal parameter is returned.
[virtual] long asLong(long defaultVal=-1) const;
This virtual member function returns the date as a number of seconds since 1-1-1970. When the instance is not valid, the string passed as the defaultVal parameter is returned.
Date and Time Format
[static] IlsString GetDefaultDateTimeFormat();
This static member function returns the default format used to convert dates to strings. The result is returned in the format understood by the strftime system function. The default is "%x - %H:%M:%S".
[static] void SetDefaultDateTimeFormat(IlsString format);
This static member function modifies the default format used to convert dates to strings. The format parameter is passed as the format understood by the strftime system function.
[static] IlsString GetDefaultTimeFormat();
This static member function returns the default format used to convert times to strings. The result is returned in the format understood by the strftime system function. The default format is "%H:%M:%S".
[static] void SetDefaultTimeFormat(IlsString format);
This static member function modifies the default format used to convert times to strings. The format parameter is passed as the format understood by the strftime system function.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.