SourcePro® 2023.1 |
SourcePro® API Reference Guide |
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 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()) | |
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 RWDBDateTime *dt) const |
int | compareTo (const RWDate *d) 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 | |
RWDBDateTime & | operator= (const RWDBDateTime &dt) |
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 |
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) |
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.
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 that provides compatibility with the old storage format.
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 |
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.
|
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.
|
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.
|
inline |
Adds num hours to self.
|
inline |
Adds num milliseconds to self.
|
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.
|
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 | ( | 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.
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.
|
inline |
Returns true
if self is between dt1 and dt2, inclusive.
|
inline |
Returns the number of bytes necessary to store self.
|
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.
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 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.
|
inline |
Returns the day of the year (1
- 366
) of self, adjusted to the given time zone.
|
inline |
Returns the day of the month (1
- 31
) of self, adjusted to the given time zone.
|
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.
|
inline |
Returns the day of the year (1
- 366
) corresponding to the first day of self's month, adjusted to the given time zone.
|
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.
|
inline |
Returns a suitable hashing value.
|
inline |
Returns the hour part of self, adjusted to the given time zone.
|
inline |
Returns self's hour in UTC (GMT).
|
inline |
Returns true
if self is during daylight-saving time in the specified time zone, otherwise returns false
.
|
inline |
Returns true
if compareTo(this, &dt) == 0, otherwise returns false
.
|
inline |
Returns true
if self represents a valid date and time, otherwise returns false
.
|
inline |
Returns true
if self represents a leap year, otherwise returns false
. Result is adjusted to the given time zone.
|
inline |
Returns the later of self and dt.
|
inline |
Returns the milliseconds part of self.
|
inline |
Returns the earlier of self and dt.
|
inline |
Returns the minutes part of self, adjusted to the given zone.
|
inline |
Returns self's minute in UTC (GMT).
|
inline |
Returns the month number (1
- 12
) of self, adjusted to the given time zone.
|
inline |
Returns the name of self's month, formatted for the given locale, adjusted to the given time zone.
|
inline |
Sets self to the current date and time.
|
inline |
Conversion operator. Used to convert an instance of RWDBDateTime to an instance of RWDateTime.
|
inline |
Assignment operator. RWDBDateTime obeys value semantics.
|
inlinestatic |
Sets the persistence to either Persistence::Default or Persistence::Legacy. This affects the member functions saveOn() and restoreFrom().
|
inlinestatic |
Returns a copy of the current persistence mechanism in use.
|
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.
|
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.
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.
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::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.
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.
|
inline |
Returns the seconds part of self.
|
inline |
Returns the number of seconds since 00:00:00 January 1, 1901 UTC.
|
inline |
Returns the weekdays number (Monday = 1
, ..., Sunday = 7
) of self, adjusted to the given time zone.
|
inline |
Returns the name of self's weekdays, formatted for the given locale, adjusted to the given time zone.
|
inline |
Returns the year part of self, adjusted to the given time zone.
|
friend |
Returns true
if dt1 is not the same as dt2, otherwise returns false
.
|
friend |
Returns true
if dt1 is before dt2, otherwise returns false
.
|
friend |
Returns true
if dt1 is earlier or the same as dt2, otherwise returns false
.
|
friend |
Returns true
if dt1 is the same as dt2, otherwise returns false
.
|
friend |
Returns true
if dt1 is after dt2, otherwise returns false
.
|
friend |
Returns true
if dt1 is after or the same as dt2, otherwise returns false
.
Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |