![]() SourcePro C++ 12.5 |
SourcePro® C++ API Reference Guide |
Product Documentation: SourcePro C++ Documentation Home |
Represents a date and time stored in milliseconds. More...
#include <rw/tools/datetime.h>
Public Types | |
| enum | Format { iso8601_compat, iso8601_2000, iso8601_midnight24, iso8601 } |
| enum | InitialState { invalid, null, setCurrentTime } |
| enum | SetType { setDate, setTime, setBoth } |
Public Member Functions | |
| RWDateTime (InitialState init_state=invalid) | |
| RWDateTime (const RWDateTime &dt) | |
| RWDateTime (rwint64 msec) | |
| RWDateTime (const struct tm *tmbuf, unsigned msec=0, const RWZone &loc=RWZone::local()) | |
| RWDateTime (const RWTime &t, unsigned msec=0) | |
| RWDateTime (const RWDate &d, unsigned hours=0, unsigned minutes=0, unsigned seconds=0, unsigned msec=0, const RWZone &zone=RWZone::local()) | |
| RWDateTime (unsigned month_day, const char *month, unsigned year, unsigned hours, unsigned minutes, unsigned seconds, unsigned msec, const RWLocale &loc=RWLocale::global(), const RWZone &zone=RWZone::local()) | |
| RWDateTime (unsigned day, unsigned month, unsigned year, unsigned hours=0, unsigned minutes=0, unsigned seconds=0, unsigned milliseconds=0, const RWZone &zone=RWZone::local()) | |
| RWDateTime (const RWCString &str, SetType set_type=setBoth, const RWLocale &loc=RWLocale::global(), const RWZone &zone=RWZone::local()) | |
| RWDateTime (const RWCString &str, Format f, const RWLocale &loc=RWLocale::global(), const RWZone &zone=RWZone::local()) | |
| RWDateTime (std::istream &s, SetType set_type, const RWLocale &loc=RWLocale::global(), const RWZone &zone=RWZone::local()) | |
| RWCString | asString (char format, const RWLocale &loc=RWLocale::global(), const RWZone &zone=RWZone::local()) const |
| RWCString | asString (const char *format, const RWLocale &loc=RWLocale::global(), const RWZone &zone=RWZone::local()) const |
| RWCString | asString (Format format, const RWLocale &loc=RWLocale::global(), const RWZone &zone=RWZone::local()) const |
| bool | between (const RWDateTime &a, const RWDateTime &b) const |
| RWspace | binaryStoreSize () const |
| int | compareTo (const RWDateTime *d) const |
| int | compareTo (const RWDateTime &d) const |
| unsigned | correctedJulian () const |
| unsigned | day (const RWZone &zone=RWZone::local()) const |
| unsigned | dayGMT () const |
| unsigned | dayOfMonth (const RWZone &zone=RWZone::local()) const |
| unsigned | dayOfMonthGMT () const |
| RWDateTime & | decrementDay (const rwint64 d) |
| RWDateTime & | decrementHour (const rwint64 h) |
| RWDateTime & | decrementMillisecond (const rwint64 msec) |
| RWDateTime & | decrementMinute (const rwint64 m) |
| RWDateTime & | decrementSecond (const rwint64 s) |
| void | extract (struct tm *tmbuf, const RWZone &zone=RWZone::local()) const |
| void | extractGMT (struct tm *tmbuf) const |
| unsigned | firstDayOfMonth (unsigned mon, const RWZone &zone=RWZone::local()) const |
| unsigned | firstDayOfMonth (const RWZone &zone=RWZone::local()) const |
| unsigned | hash () const |
| unsigned | hour (const RWZone &zone=RWZone::local()) const |
| unsigned | hourGMT () const |
| RWDateTime & | incrementDay (const rwint64 d) |
| RWDateTime & | incrementHour (const rwint64 h) |
| RWDateTime & | incrementMillisecond (const rwint64 msec) |
| RWDateTime & | incrementMinute (const rwint64 m) |
| RWDateTime & | incrementSecond (const rwint64 s) |
| bool | isDST (const RWZone &zone=RWZone::local()) const |
| bool | isFuture () const |
| bool | isInvalid () const |
| bool | isNull () const |
| bool | isPast () const |
| bool | isSentinel () const |
| bool | isValid () const |
| unsigned | julian () const |
| void | julian (unsigned j) |
| double | julianDay () const |
| void | julianDay (double j) |
| bool | leap (const RWZone &zone=RWZone::local()) const |
| bool | leapGMT () const |
| RWDateTime | max (const RWDateTime &t) const |
| unsigned | milliSecond () const |
| rwint64 | milliSeconds () const |
| RWDateTime | min (const RWDateTime &t) const |
| unsigned | minute (const RWZone &zone=RWZone::local()) const |
| unsigned | minuteGMT () const |
| unsigned | month (const RWZone &zone=RWZone::local()) const |
| unsigned | monthGMT () const |
| RWCString | monthName (const RWLocale &loc=RWLocale::global(), const RWZone &zone=RWZone::local()) const |
| RWDateTime | next (unsigned dayNum, const RWZone &zone=RWZone::local()) const |
| RWDateTime | next (const char *dayName, const RWLocale &loc=RWLocale::global(), const RWZone &zone=RWZone::local()) const |
| RWDateTime & | operator= (const RWDateTime &) |
| RWDateTime | previous (unsigned dayNum, const RWZone &zone=RWZone::local()) const |
| RWDateTime | previous (const char *dayName, const RWLocale &loc=RWLocale::global(), const RWZone &zone=RWZone::local()) const |
| std::istream & | readDate (std::istream &is) |
| std::istream & | readTime (std::istream &is) |
| void | restoreFrom (RWFile &) |
| void | restoreFrom (RWvistream &) |
| void | saveOn (RWFile &) const |
| void | saveOn (RWvostream &) const |
| unsigned | second (const RWZone &zone=RWZone::local()) const |
| unsigned | secondGMT () const |
| RWDate | toRWDate (const RWZone &zone=RWZone::local()) const |
| RWTime | toRWTime () const |
| unsigned | weekDay (const RWZone &zone=RWZone::local()) const |
| unsigned | weekDayGMT () const |
| RWCString | weekDayName (const RWLocale &loc=RWLocale::global(), const RWZone &zone=RWZone::local()) const |
| std::ostream & | writeDate (std::ostream &os) const |
| std::ostream & | writeTime (std::ostream &os) const |
| unsigned | year (const RWZone &zone=RWZone::local()) const |
| unsigned | yearGMT () const |
Static Public Member Functions | |
| static RWDateTime | beginDST (unsigned year, const RWZone &zone=RWZone::local()) |
| static unsigned | dayOfWeek (const char *day, const RWLocale &loc=RWLocale::global()) |
| static unsigned | daysInMonthYear (unsigned month, unsigned year) |
| static unsigned | daysInYear (unsigned year) |
| static bool | dayWithinMonth (unsigned month, unsigned day, unsigned year) |
| static RWDateTime | endDST (unsigned year, const RWZone &zone=RWZone::local()) |
| static unsigned | hash (const RWDateTime &dt) |
| static unsigned | indexOfMonth (const char *monthName, const RWLocale &loc=RWLocale::global()) |
| static bool | leapYear (unsigned year) |
| static RWCString | nameOfMonth (unsigned monthNum, const RWLocale &loc=RWLocale::global()) |
| static RWDateTime | now () |
| static RWDateTime | userSentinel (int n) |
| static RWCString | weekDayName (unsigned dayNum, const RWLocale &loc=RWLocale::global()) |
Static Public Attributes | |
| static const rwint64 | futureSentinel |
| static const rwint64 | invalidSentinel |
| static const rwint64 | maxDateTime |
| static const rwint64 | millisecsInDay |
| static const rwint64 | millisecsInHour |
| static const rwint64 | millisecsInMin |
| static const rwint64 | millisecsInSec |
| static const rwint64 | minDateTime |
| static const rwint64 | nullSentinel |
| static const rwint64 | pastSentinel |
| static const rwint64 | userSentinelStart |
Friends | |
| RWDateTime | operator+ (const RWDateTime &d, rwint64 s) |
| RWDateTime | operator+ (rwint64 s, const RWDateTime &d) |
| More... | |
| RWDateTime | operator- (const RWDateTime &d, rwint64 s) |
| rwint64 | operator- (const RWDateTime &dt1, const RWDateTime &dt2) |
| std::ostream & | operator<< (std::ostream &s, const RWDateTime &dt) |
| std::istream & | operator>> (std::istream &s, RWDateTime &dt) |
Related Functions | |
(Note that these are not member functions.) | |
| bool | operator!= (const RWDateTime &d1, const RWDateTime &d2) |
| bool | operator< (const RWDateTime &d1, const RWDateTime &d2) |
| RWvostream & | operator<< (RWvostream &str, const RWDateTime &t) |
| RWFile & | operator<< (RWFile &file, const RWDateTime &t) |
| bool | operator<= (const RWDateTime &d1, const RWDateTime &d2) |
| bool | operator== (const RWDateTime &d1, const RWDateTime &d2) |
| bool | operator> (const RWDateTime &d1, const RWDateTime &d2) |
| bool | operator>= (const RWDateTime &d1, const RWDateTime &d2) |
| RWvistream & | operator>> (RWvistream &str, RWDateTime &t) |
| RWFile & | operator>> (RWFile &file, RWDateTime &t) |
| RWvistream & | operator>> (RWvistream &str, RWDateTime *&t) |
| RWFile & | operator>> (RWFile &file, RWDateTime *&t) |
Class RWDateTime represents a date and time, stored in milliseconds, from January 1, 1901 00:00:00:000 UTC. Milliseconds are stored in a 64-bit integral type, which is represented by the global typedef rwint64.
RWDateTime supports the ISO 8601 international standard for the formatting of dates and times. For information and formatting syntax, see the chapter on internationalization in the Essential Tools Module User's Guide.
RWDateTime is based on the Gregorian Calendar, and its range extends for thousands of years beyond that of the deprecated RWTime. The Gregorian calendar was introduced by Pope Gregory XIII in 1582, and was adopted in various places at various times. It was adopted by England on September 14, 1752, and thus came to the United States. RWDateTime is designed for use with dates after September 14, 1752.
Four public member functions, all starting with julian, let you manipulate the date via Modified Julian days (MJD). Note that the Modified Julian day number is not the same as a date according to the Julian calendar. The Modified Julian day number is calculated using Algorithm 199 from Communications of the ACM, Volume 6, No. 8, (Aug. 1963), p. 444 and is valid for any valid Gregorian date in the Gregorian calendar. The Essential Tools Module User's Guide provides more information.
MJD = JD - 2400000.5. The half day is subtracted so that the day starts at midnight in conformance with civil time reckoning.Modified Julian days in RWDateTime function correctly from Modified Julian day 0, but can be converted only to month, date, year for Modified Julian days that fall within the Gregorian Calendar.
RWDateTime can be converted to and from RWTime and RWDate instances. Because of the greater accuracy and range, RWDateTime is the preferred class to use for dates and times.
RWDateTime instances can also be converted to and from the Standard C Library type struct tm defined in <time.h>, and listed below.
The Standard C Library Type struct tm
int tm_sec; | seconds after the minute - [0,59] |
int tm_min; | minutes after the hour - [0,59] |
int tm_hour; | hours since midnight - [0,23] |
int tm_mday; | day of the month - [1,31] |
int tm_mon; | months since January - [0,11] |
int tm_year; | years since 1900 |
int tm_wday; | days since Sunday - [0,6] |
int tm_yday; | days since January 1 - [0,365] |
int tm_isdst; | daylight savings time flag |
The default constructor for this class creates an instance with an invalid date and time, unlike RWDate and RWTime, both of which hold the current date by default. Consequently, it is much quicker to create a large array using RWDateTime than it is using RWDate. The example below illustrates the difference:
RWDateTime objects can hold a variety of sentinel values that do not refer to actual dates. Consequently it is important to know whether an object holds an actual date before performing many operations. The isSentinel() function returns true when an object holds a sentinel value.
Note that the use of the isValid() function does not determine whether a member function can be successfully applied to an object, since the null sentinel value represents a valid RWDateTime whose value is not yet determined. For more information about RWDateTime sentinels, see the section on RWDateTime Sentinels in the internationalization chapter of the Essential Tools Module User's Guide.
Simple
| enum RWDateTime::Format |
Specifies the format to be used for converting between RWCString and RWDateTime using the ISO 8601 standard. This standard converts any date and time to a locale-nonspecific numeric format.
| Enumerator | |
|---|---|
| iso8601_compat |
Parses dates, times, and date-times in the ISO 8601 standard formats as described in the ISO 8601 Compatibility Parser Reference. |
| iso8601_2000 |
Parses dates, times, and date-times in the ISO 8601:2000 standard formats as described in the ISO 8601:2000 Parser Reference. |
| iso8601_midnight24 |
Parses dates, times, and date-times in the ISO 8601:2000 standard format. When generating a string representation, midnight appears as hour 24 of the previous day rather than hour 0 of the given day. |
| iso8601 |
An alias for iso8601_2000. |
Specifies whether the constructor should construct an invalid, null, or current RWDateTime. Default is to set an invalid RWDateTime, with an undefined date and time.
| Enumerator | |
|---|---|
| invalid |
Constructs Invalid RWDateTime |
| null |
Constructs null RWDateTime |
| setCurrentTime |
Constructs RWDateTime consisting of current time |
| enum RWDateTime::SetType |
| RWDateTime::RWDateTime | ( | InitialState | init_state = invalid | ) |
Default constructor. Constructs an RWDateTime with undefined date and time. If init_state is set to RWDateTime::setCurrentTime, an instance with the current date and time is created. If init_state is set to RWDateTime::null, an instance set to null is created.
|
inline |
Copy constructor.
|
inlineexplicit |
Constructs an RWDateTime from the number of milliseconds since 1 January 1901 00:00:00:000 UTC. rwint64 is at least a 64-bit integral type. msec may be negative for representing times prior to midnight 01/01/1901.
| RWDateTime::RWDateTime | ( | const struct tm * | tmbuf, |
| unsigned | msec = 0, |
||
| const RWZone & | loc = RWZone::local() |
||
| ) |
Constructs an RWDateTime from the tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec components of the struct tm argument, with the milliseconds portion of the RWDateTime as specified by msec. The components are understood to be relative to the time zone passed in, which defaults to local time. Note that the numbering of the months and years in a struct tm differs from that used in RWDateTime arguments, which start at the number 1. The arguments included in struct tm are shown above in the class description.
The constructor tests as a precondition the struct tm pointer which cannot be null. If null, it asserts in debug builds and throws an object of type RWInternalErr in optimized builds.
| RWDateTime::RWDateTime | ( | const RWTime & | t, |
| unsigned | msec = 0 |
||
| ) |
Constructs an RWDateTime from the given RWTime using the msec argument for the number of milliseconds.
| RWDateTime::RWDateTime | ( | const RWDate & | d, |
| unsigned | hours = 0, |
||
| unsigned | minutes = 0, |
||
| unsigned | seconds = 0, |
||
| unsigned | msec = 0, |
||
| const RWZone & | zone = RWZone::local() |
||
| ) |
Constructs an RWDateTime using the RWDate d and the time h:m:s:ms. The time specified defaults to local time.
| RWDateTime::RWDateTime | ( | unsigned | month_day, |
| const char * | month, | ||
| unsigned | year, | ||
| unsigned | hours, | ||
| unsigned | minutes, | ||
| unsigned | seconds, | ||
| unsigned | msec, | ||
| const RWLocale & | loc = RWLocale::global(), |
||
| const RWZone & | zone = RWZone::local() |
||
| ) |
Constructs an RWDateTime using the specified day, month, year, hour, minute, second, and millisecond, all relative to the time zone specified, which defaults to local time. The optional locale argument loc is used to convert the month name.
| RWDateTime::RWDateTime | ( | unsigned | day, |
| unsigned | month, | ||
| unsigned | year, | ||
| unsigned | hours = 0, |
||
| unsigned | minutes = 0, |
||
| unsigned | seconds = 0, |
||
| unsigned | milliseconds = 0, |
||
| const RWZone & | zone = RWZone::local() |
||
| ) |
Constructs an RWDateTime using the specified day, month, year, hour, minute, second, and millisecond, all relative to the time zone specified, which defaults to local time.
|
explicit |
Converts the string str to a date and/or time as indicated by set_type, all relative to the time zone specified, which defaults to local time. By default, both the date and time are set using RWLocale loc. The constructor expects the date and time portions of the RWCString to be separated by a semicolon when both date and time are being set. The locale argument is used to convert the month name.
Because RWLocale cannot rigorously check date input, the member function isValid() must be used to test that the results are a valid date.
Two Examples:
| RWDateTime::RWDateTime | ( | const RWCString & | str, |
| Format | f, | ||
| const RWLocale & | loc = RWLocale::global(), |
||
| const RWZone & | zone = RWZone::local() |
||
| ) |
Constructs an RWDateTime from the string str using the format specified by f. RWDateTime currently supports the ISO 8601 format which is numeric and locale-neutral; as such the RWLocale argument is ignored for ISO 8601, but is reserved for future use. The constructor uses the RWZone argument unless the string specifies the UTC timezone or an offset from UTC, in which case the RWZone argument is ignored in favor of UTC. For more information, see the section on applying the ISO standard to timezone offsets, in the internationalization chapter of the Essential Tools Module User's Guide.
190415 could represent either or both of the following:Two Examples:
For a date or time supplied singly (for example, "2001-12-24" or "23:59:59"), RWDateTime calls the system to retrieve the current date or time.
| RWDateTime::RWDateTime | ( | std::istream & | s, |
| SetType | set_type, | ||
| const RWLocale & | loc = RWLocale::global(), |
||
| const RWZone & | zone = RWZone::local() |
||
| ) |
Reads a full line and converts it to a date and/or time as indicated by the set_type, all relative to the specified time zone, which defaults to local time. By default, both the date and time are set using the global RWLocale loc. The constructor expects the date and time portions of the RWCString to be separated by a semi-colon when both day and time are being set. The locale argument is used to convert the month name.
Because RWLocale cannot rigorously check date input, the member function isValid() must be used to test that the results are a valid date.
| RWCString RWDateTime::asString | ( | char | format, |
| const RWLocale & | loc = RWLocale::global(), |
||
| const RWZone & | zone = RWZone::local() |
||
| ) | const |
Returns the date and time as a string, formatted by the optional locale argument. The function defaults to using the RWLocale global locale.
Formats are as defined in the description for RWLocale::asString(). RWDateTime extends these formats with the addition of the 'L' format specifier, which prints the milliseconds.
| RWCString RWDateTime::asString | ( | const char * | format, |
| const RWLocale & | loc = RWLocale::global(), |
||
| const RWZone & | zone = RWZone::local() |
||
| ) | const |
Returns the date and time as a string, formatted by the optional locale argument. The function defaults to using the RWLocale global locale.
Formats are as defined in the description for RWLocale::asString(). RWDateTime extends these formats with the addition of the 'L' format specifier, which prints the milliseconds.
As a precondition, format is tested to determine if it is a null pointer. If null, the method asserts in debug mode, and throws RWInternalErr in optimized builds.
| RWCString RWDateTime::asString | ( | Format | format, |
| const RWLocale & | loc = RWLocale::global(), |
||
| const RWZone & | zone = RWZone::local() |
||
| ) | const |
Returns the date and time as a string, using the specified format.
Currently supports the ISO 8601 format. This format is numeric and locale-neutral, and as such does not use the RWLocale argument.
For more information, see the section on international standards for dates and times in the internationalization chapter of the Essential Tools Module User's Guide.
|
static |
Returns the start of daylight saving time (DST) for the given year, in the given timezone. Returns an "invalid" time if DST is not observed in that year and zone.
| bool RWDateTime::between | ( | const RWDateTime & | a, |
| const RWDateTime & | b | ||
| ) | const |
Returns true if self is between a and b, inclusive.
| RWspace RWDateTime::binaryStoreSize | ( | ) | const |
Returns the number of bytes necessary to store the object using the global function:
| int RWDateTime::compareTo | ( | const RWDateTime * | d | ) | const |
Compares self to the RWDateTime referenced by d and returns:
As a precondition, d is tested to determine if it is a null pointer. If null, the method asserts in debug mode, and throws RWInternalErr in optimized builds.
|
inline |
Compares self to the RWDateTime pointed to by d and returns:
|
inline |
Returns the value of the Julian day number. This value is one day less than the value of RWDateTime::julian() if the time is before noon UTC (GMT).
| unsigned RWDateTime::day | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns the day of the year (1-366) for this date. The default for the optional timezone argument is local.
| unsigned RWDateTime::dayGMT | ( | ) | const |
Returns the day of the year (1-366) for this date relative to UTC (GMT).
| unsigned RWDateTime::dayOfMonth | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns the day of the month (1-31) for this date. The default for the optional timezone argument is local.
| unsigned RWDateTime::dayOfMonthGMT | ( | ) | const |
Returns the day of the month (1-31) for this date relative to UTC (GMT).
|
static |
Returns the number of the day of the week corresponding to the given day, where Monday = 1, ..., Sunday = 7. Names are interpreted according to the optional locale argument. The function defaults to using the RWLocale global locale.
As a precondition, day is tested to determine if it is a null pointer. If null, the method asserts in debug mode, and throws RWInternalErr in optimized builds.
|
static |
Returns the number of days in a given month and year. Returns 0 if month is not between 1 and 12 inclusive.
|
static |
Returns the number of days in a given year.
|
static |
Returns true if day (1-31) is within a given month in a given year.
|
inline |
Decrements the class's milliseconds data member by d * millisecsInDay(), then returns self.
|
inline |
Decrements the class's milliseconds data member by h * millisecsInHour(), then returns self.
|
inline |
Decrements the class's milliseconds data member by msec, then returns self.
|
inline |
Decrements the class's milliseconds data member by m * millisecsInMin(), then returns self.
|
inline |
Decrements the class's milliseconds data member by s * millisecsInSec(), then returns self.
|
static |
Returns the end of daylight saving time for the given year, in the given timezone. Returns an "invalid time" if DST is not observed in that year and zone.
|
inline |
Returns with the struct tm argument filled out completely. Note that the encoding for months and days of the week used in struct tm differs from that used elsewhere in RWDateTime. If the date is a sentinel, the function throws an exception of type RWInternalErr.
As a precondition, tmbuf is tested to determine if it is a null pointer. If null, the method asserts in debug mode, and throws RWInternalErr in optimized builds.
|
inline |
Returns with the struct tm argument filled out completely, relative to UTC (GMT). Note that the encoding for months and days of the week used in struct tm differs from that used elsewhere in RWDateTime. If the date is a sentinel, the function throws an exception of type RWInternalErr.
As a precondition, tmbuf is tested to determine if it is a null pointer. If null, the method asserts in debug mode, and throws RWInternalErr in optimized builds.
| unsigned RWDateTime::firstDayOfMonth | ( | unsigned | mon, |
| const RWZone & | zone = RWZone::local() |
||
| ) | const |
Returns the day of the year (1-366) corresponding to the first day of mon of the year for this RWDateTime. The default for the optional timezone argument is local.
|
inline |
Returns the day of the year (1-366) corresponding to the first day of the month and year for this RWDateTime.
| unsigned RWDateTime::hash | ( | ) | const |
Returns a suitable hashing value.
|
inlinestatic |
Returns the hash value of dt as returned by dt.hash() .
| unsigned RWDateTime::hour | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns the hour relative to the timezone specified. The default for the optional timezone argument is local.
|
inline |
Returns the hour relative to UTC (GMT).
|
inline |
Increments the class's milliseconds data member by d * millisecsInDay(), then returns self.
|
inline |
Increments the class's milliseconds data member by h * millisecsInHour(), then returns self.
|
inline |
Increments the class's milliseconds data member by msec, then returns self.
|
inline |
Increments the class's milliseconds data member by m * millisecsInMin(), then returns self.
|
inline |
Increments the class's milliseconds data member by s * millisecsInSec(), then returns self.
|
static |
Returns a number between 1 and 12 corresponding to the given month name monthName. Returns 0 for no match. Months are interpreted by the optional locale argument. The function defaults to using the RWLocale global locale.
As a precondition, monthName is tested to determine if it is a null pointer. If null, the method asserts in debug mode, and throws RWInternalErr in optimized builds.
| bool RWDateTime::isDST | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns true if self is during daylight saving time in the timezone given by zone, false otherwise.
|
inline |
Returns true if self is a future sentinel.
|
inline |
Returns true if self is an invalid sentinel.
|
inline |
Returns true if self is a null sentinel.
|
inline |
Returns true if self is a past sentinel.
|
inline |
Returns true if self is a sentinel of any kind.
|
inline |
Returns true if self represents an actual time or is the null sentinel, false otherwise.
|
inline |
Returns the value of the Modified Julian day number.
| void RWDateTime::julian | ( | unsigned | j | ) |
Sets the value of the Modified Julian day number to j.
| double RWDateTime::julianDay | ( | ) | const |
Returns the value of the current date and time as a Modified Julian day number. The integer/whole number part of the double indicates the day, and the fractional part indicates the time. For example, the Modified Julian day number for 1/1/1901 is 2415386. Since Modified Julian days start at midnight GMT, 12 a.m. is 2415386.5 and 6 p.m. is 2415386.75 (these values are computed for the Greenwich meridian - a different timezone modifies the result of julianDay).
| void RWDateTime::julianDay | ( | double | j | ) |
Sets the value of the date and time to the Modified Julian day number j. The integer/whole number part of the double indicates the day, and the fractional part indicates the time. For example, the Julian day number for 1/1/1901 is 2415386. Since Julian days start at midnight GMT, 12 a.m. is 2415386.5 and 6 p.m. is 2415386.75 (these values are interpreted differently in RWDateTime objects that have different timezones).
|
inline |
Returns true if self is a leap year relative to the RWZone argument.
|
inline |
Returns true if self is a leap year relative to UTC (GMT).
|
static |
Returns true if a given year is a leap year.
|
inline |
Returns the later RWDateTime of self or t.
| unsigned RWDateTime::milliSecond | ( | ) | const |
Returns the millisecond part of self.
|
inline |
Returns the number of milliseconds since 00:00:00:000 January 1, 1901 UTC.
|
inline |
Returns the earlier RWDateTime of self or t.
| unsigned RWDateTime::minute | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns the minute, adjusted to the timezone specified.
|
inline |
Returns the minute relative to UTC (GMT).
| unsigned RWDateTime::month | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns the month (1-12) for this date. The default for the optional timezone argument is local.
| unsigned RWDateTime::monthGMT | ( | ) | const |
Returns the month (1-12) for this date relative to UTC (GMT).
| RWCString RWDateTime::monthName | ( | const RWLocale & | loc = RWLocale::global(), |
| const RWZone & | zone = RWZone::local() |
||
| ) | const |
Returns the name of the month for this date, according to the optional locale argument. The function defaults to using the RWLocale global locale.
|
static |
Returns the name of month, where January = 1, ..., December = 12. Months are interpreted by the optional locale argument. The function defaults to using the RWLocale global locale.
| RWDateTime RWDateTime::next | ( | unsigned | dayNum, |
| const RWZone & | zone = RWZone::local() |
||
| ) | const |
Returns the date of the next day of the week, where Monday = 1, ..., Sunday = 7. The variable dayNum must be between 1 and 7, inclusive. The default for the optional timezone argument is local.
| RWDateTime RWDateTime::next | ( | const char * | dayName, |
| const RWLocale & | loc = RWLocale::global(), |
||
| const RWZone & | zone = RWZone::local() |
||
| ) | const |
Returns the date of the next dayName (for example, the date of the next Monday). The weekday name is interpreted according to the optional locale argument.
As a precondition, dayName is tested to determine if it is a null pointer. If null, the method asserts in debug mode, and throws RWInternalErr in optimized builds.
|
inlinestatic |
Returns current date and time.
| RWDateTime& RWDateTime::operator= | ( | const RWDateTime & | ) |
Assignment operator.
| RWDateTime RWDateTime::previous | ( | unsigned | dayNum, |
| const RWZone & | zone = RWZone::local() |
||
| ) | const |
Returns the date of the previous numbered day of the week, where Monday = 1, ..., Sunday = 7. The variable dayNum must be between 1 and 7, inclusive. The default for the optional timezone argument is local.
| RWDateTime RWDateTime::previous | ( | const char * | dayName, |
| const RWLocale & | loc = RWLocale::global(), |
||
| const RWZone & | zone = RWZone::local() |
||
| ) | const |
Returns the day of the previous dayName; for example, the date of the previous Monday. The weekday name is interpreted according to the optional locale argument. The function defaults to using the RWLocale global locale.
| std::istream& RWDateTime::readDate | ( | std::istream & | is | ) |
Reads a full line and converts to a date according to the locale imbued on the stream. The member function isValid() must be used to test whether the results are a valid date.
| std::istream& RWDateTime::readTime | ( | std::istream & | is | ) |
Reads a full line and converts it to a time according to the locale imbued on the stream. The member function isValid() must be used to test whether the results are a valid time.
| void RWDateTime::restoreFrom | ( | RWFile & | ) |
Restores an instance of RWDateTime from a reference to an RWFile into which an instance has been persisted using the method saveOn(RWFile&)const.
| void RWDateTime::restoreFrom | ( | RWvistream & | ) |
Restores an instance of RWDateTime from a reference to a virtual stream into which an instance has been persisted using the method saveOn(RWvostream&)const.
| void RWDateTime::saveOn | ( | RWFile & | ) | const |
Saves an instance of RWDateTime to the indicated RWFile object reference. The RWDateTime can be restored using the method restoreFrom(RWFile&).
| void RWDateTime::saveOn | ( | RWvostream & | ) | const |
Saves an instance of RWDateTime to the indicated virtual stream. The RWDateTime can be restored using the method restoreFrom(RWvistream&).
| unsigned RWDateTime::second | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns the second, adjusted to the timezone specified.
|
inline |
Returns the second relative to UTC (GMT).
| RWDate RWDateTime::toRWDate | ( | const RWZone & | zone = RWZone::local() | ) | const |
Converts self to an RWDate.
|
static |
Returns user-defined sentinel number n.
| RWBoundsErr | Thrown if the argument is outside the range 0 to 127. |
| unsigned RWDateTime::weekDay | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns the number of the day of the week for this date, where Monday = 1, ..., Sunday = 7.
|
inline |
Returns the number of the day of the week for this date relative to UTC (GMT).
| RWCString RWDateTime::weekDayName | ( | const RWLocale & | loc = RWLocale::global(), |
| const RWZone & | zone = RWZone::local() |
||
| ) | const |
Returns the name of the day of the week for this date, according to the optional locale argument. The function defaults to using the RWLocale global locale.
|
static |
Returns the name of the day of the week dayNum where Monday = 1, ..., Sunday = 7. Days are interpreted by the optional locale argument. The function defaults to using the RWLocale global locale.
| std::ostream& RWDateTime::writeDate | ( | std::ostream & | os | ) | const |
Outputs the date on the std::ostream os, according to the locale imbued on the stream.
| std::ostream& RWDateTime::writeTime | ( | std::ostream & | os | ) | const |
Outputs the time on the std::ostream os, according to the locale imbued on the stream.
| unsigned RWDateTime::year | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns the year of self. The default for the optional timezone argument is local.
| unsigned RWDateTime::yearGMT | ( | ) | const |
Returns the year of self relative to UTC (GMT).
|
related |
Returns true if d1 is not the same as d2.
|
friend |
Returns the date s milliseconds in the future from the date d.
|
friend |
Returns the date s milliseconds in the future from the date d.
|
friend |
Returns the date s milliseconds in the past from d.
|
friend |
Returns the number of milliseconds between dt1 and dt2.
| RWInternalErr | Thrown if either dt1 or dt2 is a sentinel. |
|
related |
Returns true if d1 is before d2.
|
friend |
Outputs the date and time stored in dt on std::ostream s, according to the locale imbued on the stream.
|
related |
Saves t to a virtual stream.
|
related |
Saves t to an RWFile.
|
related |
Returns true if d1 is before or the same as d2.
|
related |
Returns true if d1 is the same as d2.
|
related |
Returns true if d1 is after d2.
|
related |
Return true if d1 is after or the same as d2.
|
friend |
Reads dt from std::istream s. The function reads one full line, and the string it contains is converted according to the locale imbued on the stream. The function isValid() must be used to test whether the results are a valid date.
|
related |
Restores t from a virtual stream, replacing the previous contents of t.
|
related |
Restores t from an RWFile, replacing the previous contents of t.
|
related |
Restores an RWDateTime from a virtual stream by allocating an RWDateTime on the heap and restoring its state.
|
related |
Restores an RWDateTime from an RWFile by allocating an RWDateTime on the heap and restoring its state.
|
static |
Sentinel values representing future RWDateTime sentinels.
|
static |
Sentinel values for invalid RWDateTime sentinels.
|
static |
The maximum number of milliseconds that an RWDateTime may hold.
|
static |
The number of milliseconds in a day.
|
static |
The number of milliseconds in a hour.
|
static |
The number of milliseconds in a minute.
|
static |
The number of milliseconds in a second.
|
static |
The minimum number of milliseconds that an RWDateTime may hold.
|
static |
Sentinel values for null RWDateTime sentinels.
|
static |
Sentinel values representing past RWDateTime sentinels.
|
static |
The starting value for user-defined sentinels.
© 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.
Provide feedback to Rogue Wave about its documentation.