Provides support for manipulating date/time values. More...

Public Member Functions

 SADateTime ()
 Default constructor creates empty date/time value.
 
 SADateTime (const struct tm &tmValue)
 Constructs new SADateTime object from standard C structure struct tm. More...
 
 SADateTime (double dt)
 Constructs new object from double value (DATE data type in Windows). More...
 
 SADateTime (const SAChar *szValue)
 Constructs new SADateTime object and parses a value from date/time string (ISO format or decimal number). More...
 
 SADateTime (const struct timeval &tmvValue)
 Constructs new SADateTime object from standard C structure struct timeval. More...
 
 SADateTime (const SADateTime &other)
 Copy constructor. More...
 
bool hasDate () const
 Returns true if stored date part is defined with one of SADateTime constructors.
 
bool hasTime () const
 Returns true if stored time part is defined with one of SADateTime constructors.
 
 operator struct tm & ()
 Returns a reference to the current value of SADateTime object as struct tm object. You can modify this structure directly.
 
 operator struct tm () const
 Returns struct tm object which is copied from this SADateTime object.
 
 operator double () const
 Returns a double (DATE in Windows) value whose value is calculated from this SADateTime object. More...
 
 operator SAString () const
 Returns a representation of the SADateTime object as a string (format is 'YYYY-MM-DDTHH:MI:SS').
 
bool ParseString (const SAChar *szValue)
 Parses the value from a date/time string (ISO format or decimal number).
 
int GetYear () const
 Returns the year this SADateTime object represents.
 
int GetMonth () const
 Returns the month this SADateTime object represents (1-12).
 
int GetDay () const
 Returns the day this SADateTime object represents (1-31).
 
int GetHour () const
 Returns the hour this SADateTime object represents (0-23).
 
int GetMinute () const
 Returns the minute this SADateTime object represents (0-59).
 
int GetSecond () const
 Returns the second this SADateTime object represents (0-59).
 
int GetDayOfWeek () const
 Returns the day of the week this SADateTime object represents (Sunday = 1).
 
int GetDayOfYear () const
 Returns the day of the year this SADateTime object represents (Jan 1 = 1).
 
unsigned int & Fraction ()
 Returns a reference to the fraction part of the second represented by the value of this SADateTime object. More...
 
unsigned int Fraction () const
 Returns a value of the fraction part of the second which is copied from this SADateTime object.
 
SAStringTimezone ()
 Returns a reference to the timezone represented by the value of this SADateTime object. More...
 
const SACharTimezone () const
 Returns a value of the timezone from this SADateTime object.
 
void GetTimeValue (struct timeval &tmv)
 Sets the standard C structure struct timeval to the value this SADateTime object represents. More...
 
 SADateTime (int nYear, int nMonth, int nDay)
 Constructs a SADateTime object from the specified values.
 
 SADateTime (int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec)
 Constructs a SADateTime object from the specified values.
 
 SADateTime (int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, unsigned int nFraction)
 Constructs a SADateTime object from the specified values.
 
 SADateTime (int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, const SAChar *timezone)
 Constructs a SADateTime object from the specified values.
 
 SADateTime (int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, unsigned int nFraction, const SAChar *timezone)
 Constructs a SADateTime object from the specified values.
 
 SADateTime (int nHour, int nMin, int nSec, unsigned int nFraction)
 Constructs a SADateTime object from the specified values.
 
SADateTime operator+ (SAInterval interval) const
 Arithmetic operators - accept ot return SAInterval object.
 
SADateTime operator- (SAInterval interval) const
 Arithmetic operators - accept ot return SAInterval object.
 
SADateTimeoperator+= (SAInterval interval)
 Arithmetic operators - accept ot return SAInterval object.
 
SADateTimeoperator-= (SAInterval interval)
 Arithmetic operators - accept ot return SAInterval object.
 
SAInterval operator- (const SADateTime &dt) const
 Arithmetic operators - accept ot return SAInterval object.
 

Static Public Member Functions

static SADateTime SQLAPI_CALLBACK currentDateTime ()
 Creates a SADateTime object that represents the current time (static member function).
 
static SADateTime SQLAPI_CALLBACK currentDateTimeWithFraction ()
 Creates a SADateTime object that represents the current time with fraction (static member function).
 

Detailed Description

Provides support for manipulating date/time values.

SADateTime is a subsidiary class. It is intended to replace and extend the functionality normally provided by the C run-time library date/time package. The SADateTime class supplies member functions and operators for simplified date/time handling. The class also provides constructors and operators for constructing, and assigning SADateTime objects and standard C++ date/time data types.

To create date/time value use one of SADateTime constructors:

Remarks
SADateTime object encapsulates the struct tm data type used in ANSI C also adding fraction of a second functionality.

Constructor & Destructor Documentation

◆ SADateTime() [1/5]

SADateTime::SADateTime ( const struct tm &  tmValue)

Constructs new SADateTime object from standard C structure struct tm.

Parameters
tmValueA struct tm object represents date/time value in standard C structure.

◆ SADateTime() [2/5]

SADateTime::SADateTime ( double  dt)

Constructs new object from double value (DATE data type in Windows).

Days are represented by whole number increments starting with 30 December 1899, midnight as time zero.

Hour values are expressed as the absolute value of the fractional part of the number.

Parameters
dtFloating-point value, measuring days from midnight, 30 December 1899.

◆ SADateTime() [3/5]

SADateTime::SADateTime ( const SAChar szValue)

Constructs new SADateTime object and parses a value from date/time string (ISO format or decimal number).

Parameters
szValuedate/time string (ISO format or decimal number)

◆ SADateTime() [4/5]

SADateTime::SADateTime ( const struct timeval &  tmvValue)

Constructs new SADateTime object from standard C structure struct timeval.

Parameters
tmvValueA struct timeval object represents date/time value in standard C structure used by gettimeofday routine.

◆ SADateTime() [5/5]

SADateTime::SADateTime ( const SADateTime other)

Copy constructor.

Parameters
otherA reference to the existing SADateTime object.

Member Function Documentation

◆ operator double()

SADateTime::operator double ( ) const

Returns a double (DATE in Windows) value whose value is calculated from this SADateTime object.

Returns
Double value which is calculated from this SADateTime object.
Remarks
Use these operators to get current date/time value using standard double representation. Days are represented by whole number increments starting with 30 December 1899, midnight as time zero. Hour values are expressed as the absolute value of the fractional part of the number.
Date and time Representation
30 December 1899, midnight0.00
1 January 1900, midnight 2.00
4 January 1900, midnight 5.00
4 January 1900, 6 A.M. 5.25
4 January 1900, noon 5.50
4 January 1900, 9 P.M. 5.875
Windows platform: date/time format in a double is exactly the same as used by DATE data type.

◆ Fraction()

unsigned int & SADateTime::Fraction ( )

Returns a reference to the fraction part of the second represented by the value of this SADateTime object.

You can modify this value directly.

Remarks
The value of the fraction field is the number of billionths of a second and ranges from 0 through 999,999,999 (1 less than 1 billion). For example, the value of the fraction field for a half-second is 500,000,000, for a thousandth of a second (one millisecond) is 1,000,000, for a millionth of a second (one microsecond) is 1,000, and for a billionth of a second (one nanosecond) is 1.

◆ Timezone()

SAString & SADateTime::Timezone ( )

Returns a reference to the timezone represented by the value of this SADateTime object.

You can modify this value directly.

Remarks
For the moment the value of the timezone field used with Oracle only (API functions OCIDateTimeGetTimeZoneOffset and OCIDateTimeConstruct with timezone data). The general format of the field is "[-/+]hh:mm".

◆ GetTimeValue()

void SADateTime::GetTimeValue ( struct timeval &  tmv)

Sets the standard C structure struct timeval to the value this SADateTime object represents.

Remarks
SADateTime object supposes that the stored date/time value is a local time.