rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWDBDateTime Class Reference
[Data Types]

Deprecated. Represents a date and time stored as the number of milliseconds. More...

#include <rw/db/datetime.h>

List of all members.

Public Types

enum  Persistence { Default, Legacy }

Public Member Functions

 RWDBDateTime ()
 RWDBDateTime (const RWDBDateTime &dt)
 RWDBDateTime (const RWDateTime &dt)
 RWDBDateTime (const struct tm *tm, const RWZone &zone=RWZone::local())
 RWDBDateTime (const RWTime &time, const RWZone &zone=RWZone::local())
 RWDBDateTime (const RWDate &date, unsigned hour=0, unsigned minute=0, unsigned second=0, unsigned millesecond=0, const RWZone &zone=RWZone::local())
 RWDBDateTime (const RWDate &date, const RWCString &str, const RWZone &zone=RWZone::local(), const RWLocale &locale=RWLocale::global())
 RWDBDateTime (unsigned year, unsigned month, unsigned day, unsigned hour=0, unsigned minute=0, unsigned second=0, unsigned millesecond=0, const RWZone &zone=RWZone::local())
 RWDBDateTime (unsigned long jd, unsigned hour=0, unsigned minute=0, unsigned second=0, unsigned millesecond=0, const RWZone &zone=RWZone::local())
RWspace binaryStoreSize () const
void now ()
void extract (struct tm *tmbuf, const RWZone &zone=RWZone::local()) const
unsigned hash () const
bool isValid () const
unsigned year (const RWZone &zone=RWZone::local()) const
unsigned month (const RWZone &zone=RWZone::local()) const
RWCString monthName (const RWLocale &locale=RWLocale::global(), const RWZone &zone=RWZone::local()) const
unsigned weekDay (const RWZone &zone=RWZone::local()) const
RWCString weekDayName (const RWLocale &locale=RWLocale::global(), const RWZone &zone=RWZone::local()) const
unsigned day (const RWZone &zone=RWZone::local()) const
unsigned dayOfMonth (const RWZone &zone=RWZone::local()) const
unsigned firstDayOfMonth (const RWZone &zone=RWZone::local()) const
unsigned firstDayOfMonth (unsigned month, const RWZone &zone=RWZone::local()) const
bool leap (const RWZone &zone=RWZone::local()) const
RWDBDateTime previous (unsigned dayNum, const RWZone &zone=RWZone::local()) const
RWDBDateTime previous (const char *dayName, const RWLocale &locale=RWLocale::global(), const RWZone &zone=RWZone::local()) const
unsigned hour (const RWZone &zone=RWZone::local()) const
unsigned hourGMT () const
bool isDST (const RWZone &zone=RWZone::local()) const
unsigned minute (const RWZone &timezone=RWZone::local()) const
unsigned minuteGMT () const
unsigned second () const
unsigned millisecond () const
rwint64 seconds () const
int compareTo (const RWDBDateTime *dt) const
int compareTo (const RWDate *d) const
int compareTo (const RWTime *t) const
RWDBDateTime max (const RWDBDateTime &dt) const
RWDBDateTime min (const RWDBDateTime &dt) const
bool between (const RWDBDateTime &dt1, const RWDBDateTime &dt2) const
bool isEqual (const RWDBDateTime &dt) const
RWDBDateTime addYears (long int num)
RWDBDateTime addMonths (long int num)
RWDBDateTime addDays (long int num)
RWDBDateTime addHours (rwint64 num)
RWDBDateTime addMinutes (rwint64 num)
RWDBDateTime addSeconds (rwint64 num)
RWDBDateTime addMilliseconds (rwint64 num)
RWDate rwdate () const
RWTime rwtime () const
RWCString asString (char format=(char)'\0', const RWZone &zone=RWZone::local(), const RWLocale &locale=RWLocale::global()) const
RWCString asString (const char *format, const RWZone &zone=RWZone::local(), const RWLocale &locale=RWLocale::global()) const
void saveOn (RWFile &file) const
void saveOn (RWvostream &vos) const
void restoreFrom (RWFile &file)
void restoreFrom (RWvistream &vis)
RWDBDateTimeoperator= (const RWDBDateTime &dt)
 operator RWDateTime () const

Static Public Member Functions

static void persistence (const RWDBDateTime::Persistence per)
static Persistence persistence (void)

Friends

bool operator< (const RWDBDateTime &dt1, const RWDBDateTime &dt2)
bool operator<= (const RWDBDateTime &dt1, const RWDBDateTime &dt2)
bool operator> (const RWDBDateTime &dt1, const RWDBDateTime &dt2)
bool operator>= (const RWDBDateTime &dt1, const RWDBDateTime &dt2)
bool operator== (const RWDBDateTime &dt1, const RWDBDateTime &dt2)
bool operator!= (const RWDBDateTime &dt1, const RWDBDateTime &dt2)

Detailed Description

Deprecated:
Class RWDBDateTime is deprecated. Please use RWDateTime. For more information, see Section "RWDBDateTime" in the Chapter "The Data Model" in the DB Interface Module User's Guide and the entry for RWDateTime in the Essential Tools Module Reference Guide.

RWDBDateTime represents a date and time stored as the number of milliseconds since January 1 1901 00:00:00:000 UTC. The member function isValid() can be used to determine whether an RWDBDateTime is a valid date and time. Note that RWDBDateTime is instantiated from the local system and not the database.

RWDBDateTime instances can be converted to and from RWDate, RWDateTime, and/or RWTime instances, and to and from the Standard C Library type struct tm defined in <time.h>.

Output formatting is done using an RWLocale object. The default locale formats data according to U.S. conventions. See the Essential Tools Module Reference Guide for further discussion of RWLocale.

Synopsis

 #include <rw/db/datetime.h>

 RWDBDateTime now; // construct current date and time
 RWDBDateTime then((unsigned)1993,2,27,10,2,54)

Related Classes

RWDate, RWTime, and RWDateTime can be used to create RWDBDateTime instances. Please see your Essential Tools Module documentation for information on these classes.

RWLocale is used to format the output of RWDBDateTime. Please see your Essential Tools Module documentation for information on RWLocale. Note that the character u can be used with RWLocale to denote milliseconds.


Member Enumeration Documentation

Member that provides compatibility with the old storage format.

Note:
For more information on persistence in RWDBDateTime, see Section "Persistence" in the Chapter "The Data Model" in the DB Interface Module User's Guide.
Enumerator:
Default 

Persistence model of the class is set to default; dates are stored in a new format that is compatible with RWDateTime.

Legacy 

Persistence model of the class is set to the legacy format


Constructor & Destructor Documentation

RWDBDateTime::RWDBDateTime (  ) 

The default constructor creates an instance holding the current date and time. Note that RWDBDateTime is instantiated from the local system and not the database.

RWDBDateTime::RWDBDateTime ( const RWDBDateTime dt  ) 

Copy constructor. RWDBDateTime obeys value semantics.

RWDBDateTime::RWDBDateTime ( const RWDateTime dt  )  [explicit]

Conversion constructor. Constructs an instance of RWDBDateTime from an instance of RWDateTime.

RWDBDateTime::RWDBDateTime ( const struct tm *  tm,
const RWZone zone = RWZone::local() 
)

Constructs an RWDBDateTime from the tm_year, tm_mon, tm_mday, tm_hour, tm_minute, and tm_sec components of tm, with milliseconds = 0. These components are understood to be relative to the time zone, zone, which defaults to local time. Note that the numbering of months and years in a struct tm differs from numbering in RWDBDateTime parameters.

RWDBDateTime::RWDBDateTime ( const RWTime time,
const RWZone zone = RWZone::local() 
)

Constructs an RWDBDateTime from the date and time provided by RWTime. The zone argument is ignored.

RWDBDateTime::RWDBDateTime ( const RWDate date,
unsigned  hour = 0,
unsigned  minute = 0,
unsigned  second = 0,
unsigned  millesecond = 0,
const RWZone zone = RWZone::local() 
)

Constructs an RWDBDateTime from the given date and the given time components. The time components are taken to be relative to the time zone, zone, which defaults to local time.

RWDBDateTime::RWDBDateTime ( const RWDate date,
const RWCString str,
const RWZone zone = RWZone::local(),
const RWLocale locale = RWLocale::global() 
)

Constructs an RWDBDateTime for the given date, extracting the time from the string str. The time is understood to be relative to the time zone, zone, which defaults to local time. The specified locale is used for formatting information. You can use isValid() to check the results.

RWDBDateTime::RWDBDateTime ( unsigned  year,
unsigned  month,
unsigned  day,
unsigned  hour = 0,
unsigned  minute = 0,
unsigned  second = 0,
unsigned  millesecond = 0,
const RWZone zone = RWZone::local() 
)

Constructs an RWDBDateTime from the given components. The date and time components are understood to be relative to the time zone, zone, which defaults to local time.

RWDBDateTime::RWDBDateTime ( unsigned long  jd,
unsigned  hour = 0,
unsigned  minute = 0,
unsigned  second = 0,
unsigned  millesecond = 0,
const RWZone zone = RWZone::local() 
)

Constructs an RWDBDateTime from the Julian Day number jd and the given time components. The time components are understood to be relative to the time zone, zone, which defaults to local time.


Member Function Documentation

RWDBDateTime RWDBDateTime::addDays ( long int  num  )  [inline]

Adds num days to self. The result is not necessarily a valid date. For example, April 1 2000 2:03am plus one day is not a valid date.

RWDBDateTime RWDBDateTime::addHours ( rwint64  num  )  [inline]

Adds num hours to self.

RWDBDateTime RWDBDateTime::addMilliseconds ( rwint64  num  )  [inline]

Adds num milliseconds to self.

RWDBDateTime RWDBDateTime::addMinutes ( rwint64  num  )  [inline]

Adds num minutes to self.

RWDBDateTime RWDBDateTime::addMonths ( long int  num  ) 

Adds num months to self's month part. The result is not necessarily a valid date. For example, January 31 plus one month is not a valid date.

RWDBDateTime RWDBDateTime::addSeconds ( rwint64  num  )  [inline]

Adds num seconds to self.

RWDBDateTime RWDBDateTime::addYears ( long int  num  ) 

Adds num years to self's years part. The result is not necessarily a valid date. For example, February 29 1992 plus one year is not a valid date.

RWCString RWDBDateTime::asString ( const char *  format,
const RWZone zone = RWZone::local(),
const RWLocale locale = RWLocale::global() 
) const

Returns self as a std::string, formatted by the given locale, with the time zone adjusted according to the given zone. The format string may consist of any sequence of characters containing single formats as defined by RWLocale except for the 'u' character which will print the milliseconds. The default format is the date followed by the time: 'x X'. See RWLocale in the Essential Tools Module Reference Guide for a complete listing of possible formats.

RWCString RWDBDateTime::asString ( char  format = (char)'\0',
const RWZone zone = RWZone::local(),
const RWLocale locale = RWLocale::global() 
) const

Returns self as a std::string, formatted by the given locale, with the time zone adjusted according to the given zone. The valid values for format are as defined by RWLocale except for the 'u' character which will print the milliseconds. The default format is '\0', which is the same as 'x X'. See RWLocale in the Essential Tools Module Reference Guide for a complete listing of possible formats.

bool RWDBDateTime::between ( const RWDBDateTime dt1,
const RWDBDateTime dt2 
) const [inline]

Returns true if self is between dt1 and dt2, inclusive.

RWspace RWDBDateTime::binaryStoreSize (  )  const [inline]

Returns the number of bytes necessary to store self.

int RWDBDateTime::compareTo ( const RWTime t  )  const

Comparison function. Returns -1, 0, or 1, depending upon whether self's time part is less than, equal to, or greater than the RWTime addressed by t.

int RWDBDateTime::compareTo ( const RWDate d  )  const

Comparison function. Returns -1, 0, or 1, depending upon whether self's date part is less than, equal to, or greater than the RWDate addressed by d.

int RWDBDateTime::compareTo ( const RWDBDateTime dt  )  const [inline]

Comparison function. Returns -1, 0, or 1, depending upon whether self is less than, equal to, or greater than the RWDBDateTime addressed by dt.

unsigned RWDBDateTime::day ( const RWZone zone = RWZone::local()  )  const [inline]

Returns the day of the year (1 - 366) of self, adjusted to the given time zone.

unsigned RWDBDateTime::dayOfMonth ( const RWZone zone = RWZone::local()  )  const [inline]

Returns the day of the month (1 - 31) of self, adjusted to the given time zone.

void RWDBDateTime::extract ( struct tm *  tmbuf,
const RWZone zone = RWZone::local() 
) const [inline]

Returns with the tmbuf parameter filled out entirely. Note that the encoding for months and days of the week used in struct tm differs from that used in RWDBDateTime. If self is invalid, all fields in tmbuf are set to 0 if RWZone does not observe DST, and to 1 if DST is observed.

unsigned RWDBDateTime::firstDayOfMonth ( unsigned  month,
const RWZone zone = RWZone::local() 
) const [inline]

Returns the day of the year (1 - 366) corresponding to the first day of the given month (1 - 12) in self's year, adjusted to the given time zone.

unsigned RWDBDateTime::firstDayOfMonth ( const RWZone zone = RWZone::local()  )  const [inline]

Returns the day of the year (1 - 366) corresponding to the first day of self's month, adjusted to the given time zone.

unsigned RWDBDateTime::hash (  )  const [inline]

Returns a suitable hashing value.

unsigned RWDBDateTime::hour ( const RWZone zone = RWZone::local()  )  const [inline]

Returns the hour part of self, adjusted to the given time zone.

unsigned RWDBDateTime::hourGMT (  )  const [inline]

Returns self's hour in UTC (GMT).

bool RWDBDateTime::isDST ( const RWZone zone = RWZone::local()  )  const [inline]

Returns true if self is during daylight-saving time in the specified time zone, otherwise returns false.

bool RWDBDateTime::isEqual ( const RWDBDateTime dt  )  const [inline]

Returns true if compareTo(this, &dt) == 0, otherwise returns false.

bool RWDBDateTime::isValid (  )  const [inline]

Returns true if self represents a valid date and time, otherwise returns false.

bool RWDBDateTime::leap ( const RWZone zone = RWZone::local()  )  const [inline]

Returns true if self represents a leap year, otherwise returns false. Result is adjusted to the given time zone.

RWDBDateTime RWDBDateTime::max ( const RWDBDateTime dt  )  const [inline]

Returns the later of self and dt.

unsigned RWDBDateTime::millisecond (  )  const [inline]

Returns the milliseconds part of self.

RWDBDateTime RWDBDateTime::min ( const RWDBDateTime dt  )  const [inline]

Returns the earlier of self and dt.

unsigned RWDBDateTime::minute ( const RWZone timezone = RWZone::local()  )  const [inline]

Returns the minutes part of self, adjusted to the given timezone.

unsigned RWDBDateTime::minuteGMT (  )  const [inline]

Returns self's minute in UTC (GMT).

unsigned RWDBDateTime::month ( const RWZone zone = RWZone::local()  )  const [inline]

Returns the month number (1 - 12) of self, adjusted to the given time zone.

RWCString RWDBDateTime::monthName ( const RWLocale locale = RWLocale::global(),
const RWZone zone = RWZone::local() 
) const [inline]

Returns the name of self's month, formatted for the given locale, adjusted to the given time zone.

void RWDBDateTime::now (  )  [inline]

Sets self to the current date and time.

RWDBDateTime::operator RWDateTime (  )  const [inline]

Conversion operator. Used to convert an instance of RWDBDateTime to an instance of RWDateTime.

RWDBDateTime& RWDBDateTime::operator= ( const RWDBDateTime dt  )  [inline]

Assignment operator. RWDBDateTime obeys value semantics.

static Persistence RWDBDateTime::persistence ( void   )  [inline, static]

Returns a copy of the current persistence mechanism in use.

static void RWDBDateTime::persistence ( const RWDBDateTime::Persistence  per  )  [inline, static]

Sets the persistence to either Persistence::Default or Persistence::Legacy. This affects the member functions saveOn() and restoreFrom().

RWDBDateTime RWDBDateTime::previous ( const char *  dayName,
const RWLocale locale = RWLocale::global(),
const RWZone zone = RWZone::local() 
) const [inline]

Returns an RWDBDateTime representing the previous dayName, for example, the previous Monday. The dayName is interpreted according to the given locale. Result is adjusted to the given time zone.

RWDBDateTime RWDBDateTime::previous ( unsigned  dayNum,
const RWZone zone = RWZone::local() 
) const [inline]

Returns an RWDBDateTime representing the previous numbered day of the week, where Monday = 1, ..., Sunday = 7. The parameter dayNum must be between 1 and 7, inclusive. Result is adjusted to the given time zone.

void RWDBDateTime::restoreFrom ( RWvistream vis  ) 

Reads vis, replacing contents of self. There are two ways of reading and writing the date. See the persistence() member functions or the DB Interface Module User's Guide for details.

void RWDBDateTime::restoreFrom ( RWFile file  ) 

Reads file, replacing the contents of self. There are two ways or reading and writing the date. See the persistence() member functions or the DB Interface Module User's Guide for details.

RWDate RWDBDateTime::rwdate (  )  const

Returns the date portion of self as an RWDate.

RWTime RWDBDateTime::rwtime (  )  const

Returns the time portion of self as an RWTime.

void RWDBDateTime::saveOn ( RWvostream vos  )  const

Writes contents of self to vos. There are two ways of reading and writing the date. See the persistence() member functions or the DB Interface Module User's Guide for details.

void RWDBDateTime::saveOn ( RWFile file  )  const

Writes contents of self to file. There are two ways of reading and writing the date. See the persistence() member functions or the DB Interface Module User's Guide for details.

unsigned RWDBDateTime::second (  )  const [inline]

Returns the seconds part of self.

rwint64 RWDBDateTime::seconds (  )  const [inline]

Returns the number of seconds since 00:00:00 January 1, 1901 UTC.

unsigned RWDBDateTime::weekDay ( const RWZone zone = RWZone::local()  )  const [inline]

Returns the weekdays number (Monday = 1, ..., Sunday = 7) of self, adjusted to the given time zone.

RWCString RWDBDateTime::weekDayName ( const RWLocale locale = RWLocale::global(),
const RWZone zone = RWZone::local() 
) const [inline]

Returns the name of self's weekdays, formatted for the given locale, adjusted to the given time zone.

unsigned RWDBDateTime::year ( const RWZone zone = RWZone::local()  )  const [inline]

Returns the year part of self, adjusted to the given time zone.


Friends And Related Function Documentation

bool operator!= ( const RWDBDateTime dt1,
const RWDBDateTime dt2 
) [friend]

Returns true if dt1 is not the same as dt2, otherwise returns false.

bool operator< ( const RWDBDateTime dt1,
const RWDBDateTime dt2 
) [friend]

Returns true if dt1 is before dt2, otherwise returns false.

bool operator<= ( const RWDBDateTime dt1,
const RWDBDateTime dt2 
) [friend]

Returns true if dt1 is earlier or the same as dt2, otherwise returns false.

bool operator== ( const RWDBDateTime dt1,
const RWDBDateTime dt2 
) [friend]

Returns true if dt1 is the same as dt2, otherwise returns false.

bool operator> ( const RWDBDateTime dt1,
const RWDBDateTime dt2 
) [friend]

Returns true if dt1 is after dt2, otherwise returns false.

bool operator>= ( const RWDBDateTime dt1,
const RWDBDateTime dt2 
) [friend]

Returns true if dt1 is after or the same as dt2, otherwise returns false.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.