OCILIB (C and C++ Driver for Oracle)  4.0.0
ocilib::Date Class Reference

Object identifying the SQL data type DATE. More...

#include <ocilib.hpp>

Inherits ocilib::HandleHolder< OCI_Date * >.

Public Member Functions

 Date ()
 Create an empty date object.
 
bool IsValid () const
 Check if the given date is valid.
 
int GetYear () const
 Return the date year value.
 
void SetYear (int value)
 Set the date year value.
 
int GetMonth () const
 Return the date month value.
 
void SetMonth (int value)
 Set the date month value.
 
int GetDay () const
 Return the date day value.
 
void SetDay (int value)
 Set the date day value.
 
int GetHours () const
 Return the date hours value.
 
void SetHours (int value)
 Set the date hours value.
 
int GetMinutes () const
 Return the date minutes value.
 
void SetMinutes (int value)
 Set the date minutes value.
 
int GetSeconds () const
 Return the date seconds value.
 
void SetSeconds (int value)
 Set the date seconds value.
 
int DaysBetween (const Date &other) const
 Return the number of days with the given date. More...
 
void SetDate (int year, int month, int day)
 Set the date part. More...
 
void SetTime (int hour, int min, int sec)
 Set the time part. More...
 
void SetDateTime (int year, int month, int day, int hour, int min, int sec)
 Set the date and time part. More...
 
void GetDate (int &year, int &month, int &day) const
 Extract the date parts. More...
 
void GetTime (int &hour, int &min, int &sec) const
 Extract time parts. More...
 
void GetDateTime (int &year, int &month, int &day, int &hour, int &min, int &sec) const
 Extract the date and time parts. More...
 
void AddDays (int days)
 Add or subtract days. More...
 
void AddMonths (int months)
 Add or subtract months. More...
 
void SysDate ()
 Assign the current system date time to the current date object.
 
Date NextDay (const ostring &day) const
 Return the date of next day of the week, after the current date object. More...
 
Date LastDay () const
 Return the last day of month from the current date object.
 
void ChangeTimeZone (const ostring &tzSrc, const ostring &tzDst)
 Convert the date from one zone to another zone. More...
 
void FromString (const ostring &str, const ostring &format=OCI_STRING_FORMAT_DATE)
 Assign to the date object the value provided by the input date time string. More...
 
ostring ToString (const ostring &format=OCI_STRING_FORMAT_DATE) const
 Convert the date value to a string. More...
 
Date Clone () const
 Clone the current instance to a new one performing deep copy.
 
 operator ostring () const
 Convenient operator converting the date value to a string. More...
 
Dateoperator++ ()
 Increment the date by 1 day.
 
Date operator++ (int)
 Increment the date by 1 day.
 
Dateoperator-- ()
 Decrement the date by 1 day.
 
Date operator-- (int)
 Decrement the date by 1 day.
 
Date operator+ (int value)
 Return a new date holding the current date value incremented by the given number of days.
 
Date operator- (int value)
 Return a new date holding the current date value decremented by the given number of days.
 
Dateoperator+= (int value)
 Increment the date by the given number of days.
 
Dateoperator-= (int value)
 Decrement the date by the given number of days.
 
bool operator== (const Date &other) const
 Indicates if the current date value is equal to the given date value.
 
bool operator!= (const Date &other) const
 Indicates if the current date value is not equal the given date value.
 
bool operator> (const Date &other) const
 Indicates if the current date value is superior to the given date value.
 
bool operator< (const Date &other) const
 Indicates if the current date value is inferior to the given date value.
 
bool operator>= (const Date &other) const
 Indicates if the current date value is superior or equal to the given date value.
 
bool operator<= (const Date &other) const
 Indicates if the current date value is inferior or equal to the given date value.
 

Detailed Description

Object identifying the SQL data type DATE.

This class wraps the OCILIB object handle OCI_Date and its related methods

Definition at line 2311 of file ocilib.hpp.

Member Function Documentation

int ocilib::Date::DaysBetween ( const Date other) const
inline

Return the number of days with the given date.

Parameters
other- date to compare

Definition at line 1480 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_DateDaysBetween().

void ocilib::Date::SetDate ( int  year,
int  month,
int  day 
)
inline

Set the date part.

Parameters
year- Year value
month- Month value
day- Day value

Definition at line 1485 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_DateSetDate().

Referenced by SetDay(), SetMonth(), and SetYear().

void ocilib::Date::SetTime ( int  hour,
int  min,
int  sec 
)
inline

Set the time part.

Parameters
hour- Hour value
min- Minute value
sec- Second value

Definition at line 1490 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_DateSetTime().

Referenced by SetHours(), SetMinutes(), and SetSeconds().

void ocilib::Date::SetDateTime ( int  year,
int  month,
int  day,
int  hour,
int  min,
int  sec 
)
inline

Set the date and time part.

Parameters
year- Year value
month- Month value
day- Day value
hour- Hour value
min- Minute value
sec- Second value

Definition at line 1495 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_DateSetDateTime().

void ocilib::Date::GetDate ( int &  year,
int &  month,
int &  day 
) const
inline

Extract the date parts.

Parameters
year- Place holder for year value
month- Place holder for month value
day- Place holder for day value

Definition at line 1500 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_DateGetDate().

Referenced by GetDay(), GetMonth(), GetYear(), SetDay(), SetMonth(), and SetYear().

void ocilib::Date::GetTime ( int &  hour,
int &  min,
int &  sec 
) const
inline

Extract time parts.

Parameters
hour- Place holder for hour value
min- Place holder for minute value
sec- Place holder for second value

Definition at line 1505 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_DateGetTime().

Referenced by GetHours(), GetMinutes(), GetSeconds(), SetHours(), SetMinutes(), and SetSeconds().

void ocilib::Date::GetDateTime ( int &  year,
int &  month,
int &  day,
int &  hour,
int &  min,
int &  sec 
) const
inline

Extract the date and time parts.

Parameters
year- Place holder for year value
month- Place holder for month value
day- Place holder for day value
hour- Place holder for hour value
min- Place holder for minute value
sec- Place holder for second value

Definition at line 1510 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_DateGetDateTime().

void ocilib::Date::AddDays ( int  days)
inline

Add or subtract days.

Parameters
days- Number of days to add/remove

Definition at line 1515 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_DateAddDays().

Referenced by operator+=(), and operator-=().

void ocilib::Date::AddMonths ( int  months)
inline

Add or subtract months.

Parameters
months- Number of months to add/remove

Definition at line 1520 of file ocilib_impl.hpp.

References OCI_DateAddMonths().

Date ocilib::Date::NextDay ( const ostring day) const
inline

Return the date of next day of the week, after the current date object.

Parameters
day- Day of the week

Definition at line 1530 of file ocilib_impl.hpp.

References ocilib::Check(), Clone(), and OCI_DateNextDay().

void ocilib::Date::ChangeTimeZone ( const ostring tzSrc,
const ostring tzDst 
)
inline

Convert the date from one zone to another zone.

Parameters
tzSrc- Source zone
tzDst- Destination zone

Definition at line 1548 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_DateZoneToZone().

void ocilib::Date::FromString ( const ostring str,
const ostring format = OCI_STRING_FORMAT_DATE 
)
inline

Assign to the date object the value provided by the input date time string.

Parameters
str- String date time
format- format of the date time provided in parameter 'data'
Note
For date time formats, refer to the Oracle SQL documentation

Definition at line 1553 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_DateFromText().

ostring ocilib::Date::ToString ( const ostring format = OCI_STRING_FORMAT_DATE) const
inline

Convert the date value to a string.

Parameters
format- date time format to use
Note
For date time formats, refer to the Oracle SQL documentation

Definition at line 1558 of file ocilib_impl.hpp.

References ocilib::Check(), ocilib::MakeString(), and OCI_DateToText().

ocilib::Date::operator ostring ( ) const
inline

Convenient operator converting the date value to a string.

Note
It calls ToString() with default date time format

Definition at line 1569 of file ocilib_impl.hpp.