Provides data members, member functions, and operators to manage dates and times as objects. More...
#include <ildblink/ilidtime.h>
Inherited by IldUnicodeDateTime.
Public Member Functions | |
IldDateTime (IlEnvironment *envt) | |
Initializes an empty instance of IldDateTime refers to the given environment. More... | |
IldDateTime (IlEnvironment *envt, IldDateTime &dt) | |
Initializes a new instance of IldDateTime that refers to the given environment using the value of another IldDateTime . More... | |
IldDateTime (IlEnvironment *envt, short year, IlUShort month, IlUShort day, IlUShort hour=0, IlUShort minute=0, IlUShort second=0, IlUShort msecond=0) | |
Initialializes a new instance of IldDateTime in which the data members are initialized to the provided parameter values. More... | |
virtual | ~IldDateTime () |
Cleans up the instance. More... | |
IlBoolean | get (short &y, IlUShort &mth, IlUShort &d, IlUShort &h, IlUShort &m, IlUShort &s, IlUShort &ms) |
Gets all date and time values. More... | |
IlUShort | getDay () const |
Gets the day. More... | |
IlUShort | getHour () const |
Gets the hour. More... | |
IlUShort | getMinute () const |
Gets the minutes. More... | |
IlUShort | getMonth () const |
Gets the month. More... | |
IlUShort | getMSecond () const |
Gets the millisecond. More... | |
IlUShort | getSecond () const |
Gets the second. More... | |
IlInt | getTime () const |
Gets the time. More... | |
short | getYear () const |
Gets the year. More... | |
operator IlInt () const | |
Gets the time. More... | |
void | set (short year, IlUShort month, IlUShort day, IlUShort hour, IlUShort minute, IlUShort second, IlUShort msecond=0) |
Sets the date and time. More... | |
void | setDate (short year, IlUShort month, IlUShort day) |
Sets the date. More... | |
void | setDay (IlUShort day) |
Assigns the day. More... | |
void | setHour (IlUShort hour) |
Assigns the hour. More... | |
void | setMinute (IlUShort minute) |
Assigns the minute. More... | |
void | setMonth (IlUShort month) |
Assigns the month. More... | |
void | setMSecond (IlUShort msecond) |
Assigns the millisecond. More... | |
IlBoolean | setNow () |
Sets the date and time values to be those of the exact moment this function is called. More... | |
void | setSecond (IlUShort second) |
Assigns the seconds. More... | |
void | setTime (IlUShort hour, IlUShort minute, IlUShort second, IlUShort msecond=0) |
Sets the time specification. More... | |
void | setYear (short year) |
Assigns the year. More... | |
Provides data members, member functions, and operators to manage dates and times as objects.
Library: dbkernel
By default, DB Link handles dates and times as character strings. But this choice creates dependence upon the way the client API of the particular RDBMS formats dates and times as data values. To achieve independence from the configuration of the RDBMS, DB Link defines the class IldDateTime
to handle DATE
, TIME
, DATETIME
, INTERVAL
, and TIMESTAMP
values (whichever of these exist in the RDBMS that you are accessing).
Compared to previous versions, this class has been enhance to provide internationalization capabilities. Most methods existing in former versions have been redefined to support the internationalization constraints.
The constructors and methods of the IldDateTime class are redefined but do not take into account the environment (time zone and locale); New, but equivalent, constructors are defined that take an IlEnvironment
object as their first argument. These constructors do make use, and keep a reference to, the time zone and locale set in this environment object.
If the "date as string" feature is turned off, DB Link sends dates and times to the database, or retrieves dates and times from the database, using instances of this class.
IldDateTime
as input, beware that DB Link does no checking to enforce the correctness of the value. In fact, none of the modifiers in this class check the value of their arguments. You must make sure that the value of a month is between 1 and 12, the value of a day is between 1 and 31, and so on.The range of valid years for DB Link is from -32767 to 32767. However, the range of the valid years in the particular RDBMS that you are using probably differs.
RDBMS | Range of Valid Years |
IBM DB2 | 0001 through 9999 |
Informix | 0001 through 9999 |
MS SQL | 1753 through 9999 |
ODBC | 0 through 9999 (depending on the target RDBMS) |
Oracle | -4712 through 9999 |
Sybase | 1753 through 9999 |
The accessors (member functions that begin with get
) have a range of valid values. For example, the range of valid values for getHour()
is 0 to 23. The parameter values passed to the modifiers (member functions that begin with set
) must be within the appropriate range because DB Link does not check their validity.
IldColumnType
, "Date As String" feature and "Handling Date and Time Values" in the Rogue Wave Views DB Link User's Manual. IldDateTime::IldDateTime | ( | IlEnvironment * | envt | ) |
Initializes an empty instance of IldDateTime
refers to the given environment.
envt | A valid environment object. |
Initially the value is set to the epoch origin following the UNIX convention (1970/01/01 00:00:00.000).
When retrieving the display form of the date and time object, the locale and time zone of the current environment are used.
getString()
. IldDateTime::IldDateTime | ( | IlEnvironment * | envt, |
IldDateTime & | dt | ||
) |
Initializes a new instance of IldDateTime
that refers to the given environment using the value of another IldDateTime
.
envt | A valid environment object. |
dt | An existing date time object. |
When retrieving the display form of the date and time object, the locale and time zone of the current environment are used.
getString()
. IldDateTime::IldDateTime | ( | IlEnvironment * | envt, |
short | year, | ||
IlUShort | month, | ||
IlUShort | day, | ||
IlUShort | hour = 0 , |
||
IlUShort | minute = 0 , |
||
IlUShort | second = 0 , |
||
IlUShort | msecond = 0 |
||
) |
Initialializes a new instance of IldDateTime
in which the data members are initialized to the provided parameter values.
envt | A valid environment object. |
year | The value for the year field of the date. |
month | The value for the month field of the date. |
day | The value for the day field of the date. |
hour | The value for the hour field of the time. |
minute | The value for the minute field of the time. |
second | The value for the second field of the time. |
msecond | The value for the millisecond field of the time. |
Any data member for which a parameter is not passed is initialized to 0
(zero).
The given values are supposed to be relative to the time zone from the environment.
|
virtual |
Cleans up the instance.
The environment value setting is not altered.
IlBoolean IldDateTime::get | ( | short & | y, |
IlUShort & | mth, | ||
IlUShort & | d, | ||
IlUShort & | h, | ||
IlUShort & | m, | ||
IlUShort & | s, | ||
IlUShort & | ms | ||
) |
Gets all date and time values.
y | On ouptut, will contain the year number. |
mth | On ouptut, will contain the month number. |
d | On ouptut, will contain the day number in month. |
h | On ouptut, will contain the number of hours. |
m | On ouptut, will number of minutes. |
s | On ouptut, will contain the number of seconds. |
ms | On ouptut, will contain the number of millisecond. If the number of milliseconds was not set, ms is set to 0 . |
IlTrue
if all values retrieval succeeded.isBad()
call will return IlTrue
). IlUShort IldDateTime::getDay | ( | ) | const |
Gets the day.
USHRT_MAX
). IlUShort IldDateTime::getHour | ( | ) | const |
Gets the hour.
USHRT_MAX
).The range of valid hours is 0
through 23
.
IlUShort IldDateTime::getMinute | ( | ) | const |
Gets the minutes.
USHRT_MAX
). IlUShort IldDateTime::getMonth | ( | ) | const |
Gets the month.
USHRT_MAX
).The range of valid month number starts from 1
.
IlUShort IldDateTime::getMSecond | ( | ) | const |
Gets the millisecond.
USHRT_MAX
). IlUShort IldDateTime::getSecond | ( | ) | const |
Gets the second.
USHRT_MAX
). IlInt IldDateTime::getTime | ( | ) | const |
Gets the time.
short IldDateTime::getYear | ( | ) | const |
Gets the year.
SHRT_MIN
). IldDateTime::operator IlInt | ( | ) | const |
Gets the time.
That is, it returns the same value as getTime()
.
void IldDateTime::set | ( | short | year, |
IlUShort | month, | ||
IlUShort | day, | ||
IlUShort | hour, | ||
IlUShort | minute, | ||
IlUShort | second, | ||
IlUShort | msecond = 0 |
||
) |
Sets the date and time.
year | A valid year number. |
month | A valid month number. |
day | A valid day number in month. |
hour | A valid number of hours. |
minute | A valid number of minutes. |
second | A valid number of seconds. |
msecond | A valid number of millisecond. |
setYear()
, setMonth()
, setDay()
, setHour()
, setMinute()
, setSecond()
, setMSecond()
. Sets the date.
year | A valid year number. |
month | A valid month number. |
day | A valid day number in month. |
setYear()
, setMonth()
, setDay()
. void IldDateTime::setDay | ( | IlUShort | day | ) |
Assigns the day.
day | A valid day number in month. |
1
to 31
. No internal check is made to ensure the day number is actually valid with respect to the month or year. void IldDateTime::setHour | ( | IlUShort | hour | ) |
Assigns the hour.
hour | A valid hour number. |
0
to 23
. Giving a value less than 12 will always set an AM hour. void IldDateTime::setMinute | ( | IlUShort | minute | ) |
Assigns the minute.
minute | A valid minute number. |
The range of valid minutes is 0
through 59
.
void IldDateTime::setMonth | ( | IlUShort | month | ) |
Assigns the month.
month | An assumed valid month number. |
1
. This is not the convention of the underlying ICU Calendar
class for which month numbering starts from 0
. No internal check is made to enforce the validity of the month number.getMonth()
, setYear()
. void IldDateTime::setMSecond | ( | IlUShort | msecond | ) |
Assigns the millisecond.
msecond | A valid number of milliseconds. |
The range of valid milliseconds is 0
through 999
.
IlBoolean IldDateTime::setNow | ( | ) |
Sets the date and time values to be those of the exact moment this function is called.
IlTrue
if the assignment succeeded. void IldDateTime::setSecond | ( | IlUShort | second | ) |
Assigns the seconds.
second | A valid number of seconds. |
The range of valid seconds is 0
through 59
.
Sets the time specification.
hour | A valid number of hours. |
minute | A valid number of minutes. |
second | A valid number of seconds. |
msecond | A valid number of millisecond. |
setHour()
, setMinute()
, setSecond()
, setMSecond()
. void IldDateTime::setYear | ( | short | year | ) |
Assigns the year.
year | A valid year number. |