SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWDBDateTime Class Reference

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

#include <rw/db/datetime.h>

Public Types

enum  Persistence { Default , Legacy }
 

Public Member Functions

 RWDBDateTime ()
 
 RWDBDateTime (const RWDate &date, const RWCString &str, const RWZone &zone=RWZone::local(), const RWLocale &locale=RWLocale::global())
 
 RWDBDateTime (const RWDate &date, unsigned hour=0, unsigned minute=0, unsigned second=0, unsigned millesecond=0, const RWZone &zone=RWZone::local())
 
 RWDBDateTime (const RWDateTime &dt)
 
 RWDBDateTime (const RWDBDateTime &dt)
 
 RWDBDateTime (const RWTime &time, const RWZone &zone=RWZone::local())
 
 RWDBDateTime (const struct tm *tm, 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())
 
 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 addDays (long int num)
 
RWDBDateTime addHours (rwint64 num)
 
RWDBDateTime addMilliseconds (rwint64 num)
 
RWDBDateTime addMinutes (rwint64 num)
 
RWDBDateTime addMonths (long int num)
 
RWDBDateTime addSeconds (rwint64 num)
 
RWDBDateTime addYears (long int num)
 
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
 
bool between (const RWDBDateTime &dt1, const RWDBDateTime &dt2) const
 
RWspace binaryStoreSize () const
 
int compareTo (const RWDate *d) const
 
int compareTo (const RWDBDateTime *dt) const
 
int compareTo (const RWTime *t) const
 
unsigned day (const RWZone &zone=RWZone::local()) const
 
unsigned dayOfMonth (const RWZone &zone=RWZone::local()) const
 
void extract (struct tm *tmbuf, const RWZone &zone=RWZone::local()) const
 
unsigned firstDayOfMonth (const RWZone &zone=RWZone::local()) const
 
unsigned firstDayOfMonth (unsigned month, const RWZone &zone=RWZone::local()) const
 
unsigned hash () const
 
unsigned hour (const RWZone &zone=RWZone::local()) const
 
unsigned hourGMT () const
 
bool isDST (const RWZone &zone=RWZone::local()) const
 
bool isEqual (const RWDBDateTime &dt) const
 
bool isValid () const
 
bool leap (const RWZone &zone=RWZone::local()) const
 
RWDBDateTime max (const RWDBDateTime &dt) const
 
unsigned millisecond () const
 
RWDBDateTime min (const RWDBDateTime &dt) const
 
unsigned minute (const RWZone &zone=RWZone::local()) const
 
unsigned minuteGMT () const
 
unsigned month (const RWZone &zone=RWZone::local()) const
 
RWCString monthName (const RWLocale &locale=RWLocale::global(), const RWZone &zone=RWZone::local()) const
 
void now ()
 
 operator RWDateTime () const
 
RWDBDateTimeoperator= (const RWDBDateTime &dt)
 
RWDBDateTime previous (const char *dayName, const RWLocale &locale=RWLocale::global(), const RWZone &zone=RWZone::local()) const
 
RWDBDateTime previous (unsigned dayNum, const RWZone &zone=RWZone::local()) const
 
void restoreFrom (RWFile &file)
 
void restoreFrom (RWvistream &vis)
 
RWDate rwdate () const
 
RWTime rwtime () const
 
void saveOn (RWFile &file) const
 
void saveOn (RWvostream &vos) const
 
unsigned second () const
 
rwint64 seconds () const
 
unsigned weekDay (const RWZone &zone=RWZone::local()) const
 
RWCString weekDayName (const RWLocale &locale=RWLocale::global(), const RWZone &zone=RWZone::local()) const
 
unsigned year (const RWZone &zone=RWZone::local()) 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
As of SourcePro 6, use RWDateTime instead. 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 C Standard 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)
Deprecated. Represents a date and time stored as the number of milliseconds.
Definition db/datetime.h:78
void now()
Definition db/datetime.h:168
See also

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

◆ Persistence

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() [1/9]

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() [2/9]

RWDBDateTime::RWDBDateTime ( const RWDBDateTime & dt)

Copy constructor. RWDBDateTime obeys value semantics.

◆ RWDBDateTime() [3/9]

RWDBDateTime::RWDBDateTime ( const RWDateTime & dt)
explicit

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

◆ RWDBDateTime() [4/9]

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() [5/9]

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() [6/9]

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() [7/9]

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() [8/9]

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() [9/9]

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

◆ addDays()

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.

◆ addHours()

RWDBDateTime RWDBDateTime::addHours ( rwint64 num)
inline

Adds num hours to self.

◆ addMilliseconds()

RWDBDateTime RWDBDateTime::addMilliseconds ( rwint64 num)
inline

Adds num milliseconds to self.

◆ addMinutes()

RWDBDateTime RWDBDateTime::addMinutes ( rwint64 num)
inline

Adds num minutes to self.

◆ addMonths()

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.

◆ addSeconds()

RWDBDateTime RWDBDateTime::addSeconds ( rwint64 num)
inline

Adds num seconds to self.

◆ addYears()

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.

◆ asString() [1/2]

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.

◆ asString() [2/2]

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.

◆ between()

bool RWDBDateTime::between ( const RWDBDateTime & dt1,
const RWDBDateTime & dt2 ) const
inline

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

◆ binaryStoreSize()

RWspace RWDBDateTime::binaryStoreSize ( ) const
inline

Returns the number of bytes necessary to store self.

◆ compareTo() [1/3]

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.

◆ compareTo() [2/3]

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.

◆ compareTo() [3/3]

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.

◆ day()

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.

◆ dayOfMonth()

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.

◆ extract()

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.

◆ firstDayOfMonth() [1/2]

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.

◆ firstDayOfMonth() [2/2]

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.

◆ hash()

unsigned RWDBDateTime::hash ( ) const
inline

Returns a suitable hashing value.

◆ hour()

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

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

◆ hourGMT()

unsigned RWDBDateTime::hourGMT ( ) const
inline

Returns self's hour in UTC (GMT).

◆ isDST()

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.

◆ isEqual()

bool RWDBDateTime::isEqual ( const RWDBDateTime & dt) const
inline

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

◆ isValid()

bool RWDBDateTime::isValid ( ) const
inline

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

◆ leap()

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.

◆ max()

RWDBDateTime RWDBDateTime::max ( const RWDBDateTime & dt) const
inline

Returns the later of self and dt.

◆ millisecond()

unsigned RWDBDateTime::millisecond ( ) const
inline

Returns the milliseconds part of self.

◆ min()

RWDBDateTime RWDBDateTime::min ( const RWDBDateTime & dt) const
inline

Returns the earlier of self and dt.

◆ minute()

unsigned RWDBDateTime::minute ( const RWZone & zone = RWZone::local()) const
inline

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

◆ minuteGMT()

unsigned RWDBDateTime::minuteGMT ( ) const
inline

Returns self's minute in UTC (GMT).

◆ month()

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

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

◆ monthName()

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.

◆ now()

void RWDBDateTime::now ( )
inline

Sets self to the current date and time.

◆ operator RWDateTime()

RWDBDateTime::operator RWDateTime ( ) const
inline

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

◆ operator=()

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

Assignment operator. RWDBDateTime obeys value semantics.

◆ persistence() [1/2]

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

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

◆ persistence() [2/2]

static Persistence RWDBDateTime::persistence ( void )
inlinestatic

Returns a copy of the current persistence mechanism in use.

◆ previous() [1/2]

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.

◆ previous() [2/2]

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.

◆ restoreFrom() [1/2]

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.

◆ restoreFrom() [2/2]

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.

◆ rwdate()

RWDate RWDBDateTime::rwdate ( ) const

Returns the date portion of self as an RWDate.

◆ rwtime()

RWTime RWDBDateTime::rwtime ( ) const

Returns the time portion of self as an RWTime.

◆ saveOn() [1/2]

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.

◆ saveOn() [2/2]

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.

◆ second()

unsigned RWDBDateTime::second ( ) const
inline

Returns the seconds part of self.

◆ seconds()

rwint64 RWDBDateTime::seconds ( ) const
inline

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

◆ weekDay()

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.

◆ weekDayName()

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.

◆ year()

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 Symbol Documentation

◆ operator!=

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

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

◆ operator<

bool operator< ( const RWDBDateTime & dt1,
const RWDBDateTime & dt2 )
friend

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

◆ operator<=

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

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

◆ operator==

bool operator== ( const RWDBDateTime & dt1,
const RWDBDateTime & dt2 )
friend

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

◆ operator>

bool operator> ( const RWDBDateTime & dt1,
const RWDBDateTime & dt2 )
friend

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

◆ operator>=

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

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

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.