SourcePro® 2024.1 |
SourcePro® API Reference Guide |
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 (const RWCString &str, Format f, const RWLocale &loc=RWLocale::global(), 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 RWDate &d, unsigned hours=0, unsigned minutes=0, unsigned seconds=0, unsigned msec=0, const RWZone &zone=RWZone::local()) | |
RWDateTime (const RWDateTime &dt) | |
RWDateTime (const RWTime &t, unsigned msec=0) | |
RWDateTime (const RWTimeTuple &tt, const RWZone &zone=RWZone::local()) | |
RWDateTime (const RWTimeTupleOffset &tt) | |
RWDateTime (const struct tm *tmbuf, unsigned msec=0, const RWZone &loc=RWZone::local()) | |
RWDateTime (InitialState init_state=invalid) | |
RWDateTime (rwint64 msec) | |
RWDateTime (std::istream &s, SetType set_type, 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 (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()) | |
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 (const RWZone &zone=RWZone::local()) const |
unsigned | firstDayOfMonth (unsigned mon, 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 (const char *dayName, const RWLocale &loc=RWLocale::global(), const RWZone &zone=RWZone::local()) const |
RWDateTime | next (unsigned dayNum, const RWZone &zone=RWZone::local()) const |
RWDateTime & | operator= (const RWDateTime &) |
RWDateTime | previous (const char *dayName, const RWLocale &loc=RWLocale::global(), const RWZone &zone=RWZone::local()) const |
RWDateTime | previous (unsigned dayNum, 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) |
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 Symbols | |
(Note that these are not member symbols.) | |
bool | operator!= (const RWDateTime &d1, const RWDateTime &d2) |
bool | operator< (const RWDateTime &d1, const RWDateTime &d2) |
RWFile & | operator<< (RWFile &file, const RWDateTime &t) |
RWvostream & | operator<< (RWvostream &str, 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) |
RWFile & | operator>> (RWFile &file, RWDateTime &t) |
RWFile & | operator>> (RWFile &file, RWDateTime *&t) |
RWvistream & | operator>> (RWvistream &str, RWDateTime &t) |
RWvistream & | operator>> (RWvistream &str, 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 proleptic Gregorian calendar. It applies Gregorian calendar rules for dates in the future as well as those prior to its introduction in 1582.
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 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.An RWDateTime can be converted to and from an RWDate instance. RWDate represents a date with no time component and does not change according to the time zone. In contrast, RWDateTime represents a date and time and varies depending on the time zone in which the date and time data is retrieved.
RWDateTime instances can also be converted to and from the C Standard Library type struct tm
defined in <time.h>
, and listed below.
The C Standard 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, which holds 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.
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.
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 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.
This constructor produces a valid RWDateTime instance for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to create an RWDateTime with values outside this range will result in undefined behavior.
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 specified by hours, minutes, seconds, and msec. The time specified defaults to local time.
|
explicit |
Constructs an RWDateTime using the RWTimeTuple tt in the specified time zone zone. The picosecond value of tt is rounded down to the nearest millisecond.
If tt represents a time before RWDateTime::minDateTime, an RWDateTime::pastSentinel value is constructed.
If tt represents a time after RWDateTime::maxDateTime, an RWDateTime::futureSentinel value is constructed.
|
explicit |
Constructs an RWDateTime using the RWTimeTupleOffset tt. The picosecond value of tt is rounded down to the nearest millisecond.
If tt represents a time before RWDateTime::minDateTime, an RWDateTime::pastSentinel value is constructed.
If tt represents a time after RWDateTime::maxDateTime, an RWDateTime::futureSentinel value is constructed.
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.
This constructor produces a valid RWDateTime instance for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to create an RWDateTime with values outside this range will result in undefined behavior.
As a precondition, month is tested to determine if it is a null pointer. If null, the method asserts in debug mode, and throws RWInternalErr in optimized builds.
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.
This constructor produces a valid RWDateTime instance for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to create an RWDateTime with values outside this range will result in undefined behavior.
|
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.
This constructor handles years 0 to 9999. Passing a string with a year outside this range will result in undefined behavior. Year values 0 to 99 are treated differently based on how the library was built. In all builds that do not define the macro RW_CENTURY_REQD, years 0 to 99 are treated as 1900 to 1999. Debug builds that define the macro will produce a debug assertion. Release builds that define the macro will produce an invalid RWDateTime instance.
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 time zone 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 time zone offsets, in the internationalization chapter of the Essential Tools Module User's Guide.
This constructor handles four-digit year values 0000 to 9999. Passing a string with a year value that is not exactly four digits or is outside of this range will result in undefined behavior.
Please note that confusion can occur when using a string that contains only a date or only a time indication, since it is not possible to differentiate between some representations of the two formats. For example. the string 190415
could represent either or both of the following:
You can avoid such confusion by using more explicit formats. For example, you can completely and safely avoid all confusion if you are prepend "T" (allowed by the standard in time-only indications) for all times or if you always use extended formats.
For more information, see the section on applying the ISO standard to time zone offsets, in the internationalization chapter of the Essential Tools Module User's Guide.
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 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.
This constructor handles years 0 to 9999. Passing a string with a year outside this range will result in undefined behavior.
Year values 0 to 99 are treated differently based on how the library was built. In all builds that do not define the macro RW_CENTURY_REQD, years 0 to 99 are treated as 1900 to 1999. Debug builds that define the macro will produce a debug assertion. Release builds that define the macro will produce an invalid RWDateTime instance.
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.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
The following table specifies the string produced for a given sentinel value.
Sentinel value | String produced |
---|---|
RWDateTime::nullSentinel | "NULL" |
RWDateTime::futureSentinel | "#INVALID#" |
RWDateTime::pastSentinel | "#INVALID#" |
RWDateTime::invalidSentinel | "#INVALID#" |
RWDateTime::userSentinel() | "#>n<#" where n is the integer passed to RWDateTime::userSentinel() |
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.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
The following table specifies the string produced for a given sentinel value.
Sentinel value | String produced |
---|---|
RWDateTime::nullSentinel | "NULL" |
RWDateTime::futureSentinel | "#INVALID#" |
RWDateTime::pastSentinel | "#INVALID#" |
RWDateTime::invalidSentinel | "#INVALID#" |
RWDateTime::userSentinel() | "#>n<#" where n is the integer passed to RWDateTime::userSentinel() |
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 in the form "YYYY-MM-DD'T'hh:mm:ss[,sss]['Z'][+/-hh:mm]"
. This format is numeric and locale-neutral, and as such does not use the RWLocale argument.
The milliseconds portion of the string will appear when the milliseconds value is non-zero.
'Z' appears at the end of the formatted string when the zone is UTC. Otherwise, the hour and minute offset from UTC is formatted.
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.
This method produces a valid output for date-time values between 0000-01-01T00:00:00 and 9999-12-31T23:59:59,999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
static |
Returns the first transition to daylight saving time (DST) for year in zone. Returns an RWDateTime::invalidSentinel if a daylight transition does not occur in that year and time 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:
|
inline |
Compares self to the RWDateTime referenced by d and returns:
int RWDateTime::compareTo | ( | const RWDateTime * | d | ) | const |
Compares self to the RWDateTime pointed to 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 |
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).
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
unsigned RWDateTime::day | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns the day of the year (1-366) for this date. The default for zone is local.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
unsigned RWDateTime::dayGMT | ( | ) | const |
Returns the day of the year (1-366) for this date relative to UTC (GMT).
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
unsigned RWDateTime::dayOfMonth | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns the day of the month (1-31) for this date. The default for zone is local.
unsigned RWDateTime::dayOfMonthGMT | ( | ) | const |
Returns the day of the month (1-31) for this date relative to UTC (GMT).
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
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 first transition away from daylight saving time (DST) for year in zone. Returns an RWDateTime::invalidSentinel if a daylight transition does not occur in that year and time 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.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
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.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
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 the day of the year (1-366) corresponding to the first day of the month and year for this RWDateTime.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
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 zone is local.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
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 zone. The default for zone is local.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
inline |
Returns the hour relative to UTC (GMT).
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
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 time zone given by zone, false
otherwise.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
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.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
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 time zone modifies the result of julianDay
).
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
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 time zones).
This method produces a valid output for values of j from 0 to the maximum value that can be stored in an unsigned
. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
inline |
Returns true
if self is a leap year relative to the RWZone argument.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
inline |
Returns true
if self is a leap year relative to UTC (GMT).
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
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 zone.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
inline |
Returns the minute relative to UTC (GMT).
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
unsigned RWDateTime::month | ( | const RWZone & | zone = RWZone::local() | ) | const |
Returns the month (1-12) for this date. The default for zone is local.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
unsigned RWDateTime::monthGMT | ( | ) | const |
Returns the month (1-12) for this date relative to UTC (GMT).
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
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.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
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 | ( | 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.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
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.
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 zone is local.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
inlinestatic |
Returns current date and time.
RWDateTime & RWDateTime::operator= | ( | const RWDateTime & | ) |
Assignment operator.
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.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
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.
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 zone is local.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
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.
This method handles date values with years in the range 0 to 9999. Passing a stream that holds a year outside this range will result in undefined behavior. Year values 0 to 99 are treated differently based on how the library was built. In all builds that do not define the macro RW_CENTURY_REQD, years 0 to 99 are treated as 1900 to 1999. Debug builds that define the macro will produce a debug assertion. Release builds that define the macro will produce an invalid RWDateTime instance.
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 zone.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
inline |
Returns the second relative to UTC (GMT).
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
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.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
inline |
Returns the number of the day of the week for this date relative to UTC (GMT).
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
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.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
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 zone is local.
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000 and 11754508-12-13T23:59:59.999 in the specified time zone. Attempts to invoke this method with values outside that range will result in undefined behavior.
unsigned RWDateTime::yearGMT | ( | ) | const |
Returns the year of self relative to UTC (GMT).
This method produces a valid output for date-time values between -4713-11-24T00:00:00.000Z and 11754508-12-13T23:59:59.999Z. Attempts to invoke this method with values outside that range will result in undefined behavior.
|
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.
|
related |
Saves t to an RWFile.
|
related |
Saves t to a virtual stream.
|
friend |
Outputs the date and time stored in dt on std::ostream s. The output produced behaves as if a call was made to asString(char, const RWLocale&, const RWZone&)const with the 'c' format specifier passed as the first argument, and the locale imbued on the stream s passed as the second argument.
|
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.
|
related |
Restores t from an RWFile, replacing the previous contents of t.
|
related |
Restores an RWDateTime from an RWFile by allocating an RWDateTime on the heap and restoring its state.
|
related |
Restores t from a virtual stream, 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.
|
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. If the string cannot be converted to an RWDateTime, dt is set to RWDateTime::invalid.
|
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 © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |