SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWDateTime Class Reference

Represents a date and time stored in milliseconds. More...

#include <rw/tools/datetime.h>

Inheritance diagram for RWDateTime:
RWCollectableDateTime

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
 
RWDateTimedecrementDay (const rwint64 d)
 
RWDateTimedecrementHour (const rwint64 h)
 
RWDateTimedecrementMillisecond (const rwint64 msec)
 
RWDateTimedecrementMinute (const rwint64 m)
 
RWDateTimedecrementSecond (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
 
RWDateTimeincrementDay (const rwint64 d)
 
RWDateTimeincrementHour (const rwint64 h)
 
RWDateTimeincrementMillisecond (const rwint64 msec)
 
RWDateTimeincrementMinute (const rwint64 m)
 
RWDateTimeincrementSecond (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
 
RWDateTimeoperator= (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)
 
RWFileoperator<< (RWFile &file, const RWDateTime &t)
 
RWvostreamoperator<< (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)
 
RWFileoperator>> (RWFile &file, RWDateTime &t)
 
RWFileoperator>> (RWFile &file, RWDateTime *&t)
 
RWvistreamoperator>> (RWvistream &str, RWDateTime &t)
 
RWvistreamoperator>> (RWvistream &str, RWDateTime *&t)
 

Detailed Description

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.

Note
The modern Modified Julian Day (MJD) was introduced in the 1950s and starts at midnight, as opposed to the historic Julian Day (JD), which began at 12 noon. MJD is defined as MJD = JD - 2400000.5. The half day is subtracted so that the day starts at midnight in conformance with civil time reckoning.
Two-digit year specifiers assume the century 1900, so you should create programs that use four-digit year specifiers. You can enforce the use of a four-digit year by defining the build macro RW_CENTURY_REQD in RCB when building the libraries. Be aware, however, that defining this macro requires a four-digit year to be provided when constructing an RWDateTime. For more information, see the section on RWDateTime in the Essential Tools Module User's Guide.

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.

Note
RWTime is deprecated and so are all methods that either take or return instances of this class. Deprecation means that these classes and related methods are no longer supported, and may be removed in a future release.

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:

// Figures out the current date 5000 times
RWDate v[5000];
// Creates an array with 5000 undefined dates and times
RWDateTime v[5000];
Represents a date and time stored in milliseconds.
Definition tools/datetime.h:219
Represents a date stored as a Julian day number.
Definition rwdate.h:112

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.

Synopsis
#include <rw/tools/datetime.h>
RWDateTime dt(RWDateTime::setCurrentTime); // construct today's date
@ setCurrentTime
Definition tools/datetime.h:241
Persistence
Simple
Example
#include <rw/tools/datetime.h>
#include <iostream>
int main() {
// Today's date
// Last Sunday's date
RWDateTime lastSunday = dt.previous("Sunday");
std::cout << dt << std::endl << lastSunday << std::endl;
}
RWDateTime previous(unsigned dayNum, const RWZone &zone=RWZone::local()) const

Member Enumeration Documentation

◆ 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 
Deprecated
As of SourcePro 14, use iso8601 instead.

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.

◆ InitialState

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

◆ SetType

Specifies whether the constructor should set just the date, just the time, or both. Default is to set both.

Enumerator
setDate 

Sets the date

setTime 

Sets the time

setBoth 

Sets both the date and the time

Constructor & Destructor Documentation

◆ RWDateTime() [1/13]

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.

◆ RWDateTime() [2/13]

RWDateTime::RWDateTime ( const RWDateTime & dt)
inline

Copy constructor.

◆ RWDateTime() [3/13]

RWDateTime::RWDateTime ( rwint64 msec)
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() [4/13]

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

RWDateTime::RWDateTime ( const RWTime & t,
unsigned msec = 0 )
Deprecated
As of SourcePro 10. Provided for compatibility with code that relies on the deprecated RWTime type.

Constructs an RWDateTime from the given RWTime using the msec argument for the number of milliseconds.

◆ RWDateTime() [6/13]

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.

◆ RWDateTime() [7/13]

RWDateTime::RWDateTime ( const RWTimeTuple & tt,
const RWZone & zone = RWZone::local() )
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.

◆ RWDateTime() [8/13]

RWDateTime::RWDateTime ( const RWTimeTupleOffset & tt)
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() [9/13]

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

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.

◆ RWDateTime() [11/13]

RWDateTime::RWDateTime ( const RWCString & str,
SetType set_type = setBoth,
const RWLocale & loc = RWLocale::global(),
const RWZone & zone = RWZone::local() )
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("April 4, 1998; 10:00 am", RWDateTime::setBoth,
RWLocale::global()); // sets date and time
RWLocale::global()); // sets date and initializes
// time to 00:00:00
RWDateTime(InitialState init_state=invalid)
@ setDate
Definition tools/datetime.h:253
@ setBoth
Definition tools/datetime.h:263
static const RWLocale & global()
RWLocale::global()); // initializes date to
// today at time 10:00
@ setTime
Definition tools/datetime.h:258

◆ RWDateTime() [12/13]

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.

Note

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:

  • date: the 15th day of the 4th month of the 19th year in the default century
  • time: 19:04:15

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:

RWDateTime("1998-04-04T00:00:00-08:00", RWDateTime::iso8601,
@ iso8601_midnight24
Definition tools/datetime.h:303
@ iso8601
Definition tools/datetime.h:308
RWLocale::global()); // initializes time to
// 00:00:00
RWLocale::global()); // initializes date to
// current system date

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

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.

Member Function Documentation

◆ asString() [1/3]

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()

◆ asString() [2/3]

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.

◆ asString() [3/3]

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.

◆ beginDST()

static RWDateTime RWDateTime::beginDST ( unsigned year,
const RWZone & zone = RWZone::local() )
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.

◆ between()

bool RWDateTime::between ( const RWDateTime & a,
const RWDateTime & b ) const

Returns true if self is between a and b, inclusive.

◆ binaryStoreSize()

RWspace RWDateTime::binaryStoreSize ( ) const

Returns the number of bytes necessary to store the object using the global function:

friend std::ostream & operator<<(std::ostream &s, const RWDateTime &dt)
Represents an abstraction of a filesystem regular file.
Definition rwfile.h:68

◆ compareTo() [1/2]

int RWDateTime::compareTo ( const RWDateTime & d) const
inline

Compares self to the RWDateTime referenced by d and returns:

0 if self == d
1 if self > d
-1 if self < d

◆ compareTo() [2/2]

int RWDateTime::compareTo ( const RWDateTime * d) const

Compares self to the RWDateTime pointed to by d and returns:

0 if self == *d
1 if self > *d
-1 if self < *d

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.

◆ correctedJulian()

unsigned RWDateTime::correctedJulian ( ) const
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.

◆ day()

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.

Note
This method throws an exception if called on a sentinel date. Otherwise, it returns a valid day of year.

◆ dayGMT()

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.

Note
This method throws an exception if called on a sentinel date. Otherwise, it returns a valid day of year.

◆ dayOfMonth()

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.

◆ dayOfMonthGMT()

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.

◆ dayOfWeek()

static unsigned RWDateTime::dayOfWeek ( const char * day,
const RWLocale & loc = RWLocale::global() )
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.

◆ daysInMonthYear()

static unsigned RWDateTime::daysInMonthYear ( unsigned month,
unsigned year )
static

Returns the number of days in a given month and year. Returns 0 if month is not between 1 and 12 inclusive.

◆ daysInYear()

static unsigned RWDateTime::daysInYear ( unsigned year)
static

Returns the number of days in a given year.

◆ dayWithinMonth()

static bool RWDateTime::dayWithinMonth ( unsigned month,
unsigned day,
unsigned year )
static

Returns true if day (1-31) is within a given month in a given year.

◆ decrementDay()

RWDateTime & RWDateTime::decrementDay ( const rwint64 d)
inline

Decrements the class's milliseconds data member by d * millisecsInDay(), then returns self.

Note
if this operation results in crossing a DST boundary in the instance's time zone, outputting the date will present with a DST offset as well.

◆ decrementHour()

RWDateTime & RWDateTime::decrementHour ( const rwint64 h)
inline

Decrements the class's milliseconds data member by h * millisecsInHour(), then returns self.

Note
If this operation results in crossing a DST boundary in the instance's time zone, outputting the date will present with a DST offset as well.

◆ decrementMillisecond()

RWDateTime & RWDateTime::decrementMillisecond ( const rwint64 msec)
inline

Decrements the class's milliseconds data member by msec, then returns self.

Note
If this operation results in crossing a DST boundary in the instance's time zone, outputting the date will present with a DST offset as well.

◆ decrementMinute()

RWDateTime & RWDateTime::decrementMinute ( const rwint64 m)
inline

Decrements the class's milliseconds data member by m * millisecsInMin(), then returns self.

Note
If this operation results in crossing a DST boundary in the instance's time zone, outputting the date will present with a DST offset as well.

◆ decrementSecond()

RWDateTime & RWDateTime::decrementSecond ( const rwint64 s)
inline

Decrements the class's milliseconds data member by s * millisecsInSec(), then returns self.

Note
If this operation results in crossing a DST boundary in the instance's time zone, outputting the date will present with a DST offset as well.

◆ endDST()

static RWDateTime RWDateTime::endDST ( unsigned year,
const RWZone & zone = RWZone::local() )
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.

◆ extract()

void RWDateTime::extract ( struct tm * tmbuf,
const RWZone & zone = RWZone::local() ) const
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.

◆ extractGMT()

void RWDateTime::extractGMT ( struct tm * tmbuf) const
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.

◆ firstDayOfMonth() [1/2]

unsigned RWDateTime::firstDayOfMonth ( const RWZone & zone = RWZone::local()) const
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.

◆ firstDayOfMonth() [2/2]

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.

◆ hash() [1/2]

unsigned RWDateTime::hash ( ) const

Returns a suitable hashing value.

◆ hash() [2/2]

static unsigned RWDateTime::hash ( const RWDateTime & dt)
inlinestatic

Returns the hash value of dt as returned by dt.hash() .

◆ hour()

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.

◆ hourGMT()

unsigned RWDateTime::hourGMT ( ) const
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.

◆ incrementDay()

RWDateTime & RWDateTime::incrementDay ( const rwint64 d)
inline

Increments the class's milliseconds data member by d * millisecsInDay(), then returns self.

Note
If this operation results in crossing a DST boundary in the instance's time zone, outputting the date will present with a DST offset as well.

◆ incrementHour()

RWDateTime & RWDateTime::incrementHour ( const rwint64 h)
inline

Increments the class's milliseconds data member by h * millisecsInHour(), then returns self.

Note
If this operation results in crossing a DST boundary in the instance's time zone, outputting the date will present with a DST offset as well.

◆ incrementMillisecond()

RWDateTime & RWDateTime::incrementMillisecond ( const rwint64 msec)
inline

Increments the class's milliseconds data member by msec, then returns self.

Note
If this operation results in crossing a DST boundary in the instance's time zone, outputting the date will present with a DST offset as well.

◆ incrementMinute()

RWDateTime & RWDateTime::incrementMinute ( const rwint64 m)
inline

Increments the class's milliseconds data member by m * millisecsInMin(), then returns self.

Note
If this operation results in crossing a DST boundary in the instance's time zone, outputting the date will present with a DST offset as well.

◆ incrementSecond()

RWDateTime & RWDateTime::incrementSecond ( const rwint64 s)
inline

Increments the class's milliseconds data member by s * millisecsInSec(), then returns self.

Note
If this operation results in crossing a DST boundary in the instance's time zone, outputting the date will present with a DST offset as well.

◆ indexOfMonth()

static unsigned RWDateTime::indexOfMonth ( const char * monthName,
const RWLocale & loc = RWLocale::global() )
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.

◆ isDST()

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.

◆ isFuture()

bool RWDateTime::isFuture ( ) const
inline

Returns true if self is a future sentinel.

◆ isInvalid()

bool RWDateTime::isInvalid ( ) const
inline

Returns true if self is an invalid sentinel.

◆ isNull()

bool RWDateTime::isNull ( ) const
inline

Returns true if self is a null sentinel.

◆ isPast()

bool RWDateTime::isPast ( ) const
inline

Returns true if self is a past sentinel.

◆ isSentinel()

bool RWDateTime::isSentinel ( ) const
inline

Returns true if self is a sentinel of any kind.

◆ isValid()

bool RWDateTime::isValid ( ) const
inline

Returns true if self represents an actual time or is the null sentinel, false otherwise.

◆ julian() [1/2]

unsigned RWDateTime::julian ( ) const
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.

◆ julian() [2/2]

void RWDateTime::julian ( unsigned j)

Sets the value of the Modified Julian day number to j.

◆ julianDay() [1/2]

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.

◆ julianDay() [2/2]

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.

◆ leap()

bool RWDateTime::leap ( const RWZone & zone = RWZone::local()) const
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.

◆ leapGMT()

bool RWDateTime::leapGMT ( ) const
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.

◆ leapYear()

static bool RWDateTime::leapYear ( unsigned year)
static

Returns true if a given year is a leap year.

◆ max()

RWDateTime RWDateTime::max ( const RWDateTime & t) const
inline

Returns the later RWDateTime of self or t.

◆ milliSecond()

unsigned RWDateTime::milliSecond ( ) const

Returns the millisecond part of self.

◆ milliSeconds()

rwint64 RWDateTime::milliSeconds ( ) const
inline

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

◆ min()

RWDateTime RWDateTime::min ( const RWDateTime & t) const
inline

Returns the earlier RWDateTime of self or t.

◆ minute()

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.

◆ minuteGMT()

unsigned RWDateTime::minuteGMT ( ) const
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.

◆ month()

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.

◆ monthGMT()

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.

◆ monthName()

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.

◆ nameOfMonth()

static RWCString RWDateTime::nameOfMonth ( unsigned monthNum,
const RWLocale & loc = RWLocale::global() )
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.

◆ next() [1/2]

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.

◆ next() [2/2]

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.

◆ now()

static RWDateTime RWDateTime::now ( )
inlinestatic

Returns current date and time.

◆ operator=()

RWDateTime & RWDateTime::operator= ( const RWDateTime & )

Assignment operator.

◆ previous() [1/2]

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.

◆ previous() [2/2]

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.

◆ readDate()

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.

◆ readTime()

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.

◆ restoreFrom() [1/2]

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.

◆ restoreFrom() [2/2]

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.

◆ saveOn() [1/2]

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&).

◆ saveOn() [2/2]

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&).

◆ second()

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.

◆ secondGMT()

unsigned RWDateTime::secondGMT ( ) const
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.

◆ toRWDate()

RWDate RWDateTime::toRWDate ( const RWZone & zone = RWZone::local()) const

Converts self to an RWDate.

◆ toRWTime()

RWTime RWDateTime::toRWTime ( ) const

Converts self to an RWTime.

◆ userSentinel()

static RWDateTime RWDateTime::userSentinel ( int n)
static

Returns user-defined sentinel number n.

Exceptions
RWBoundsErrThrown if the argument is outside the range 0 to 127.

◆ weekDay()

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.

◆ weekDayGMT()

unsigned RWDateTime::weekDayGMT ( ) const
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.

◆ weekDayName() [1/2]

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.

◆ weekDayName() [2/2]

static RWCString RWDateTime::weekDayName ( unsigned dayNum,
const RWLocale & loc = RWLocale::global() )
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.

◆ writeDate()

std::ostream & RWDateTime::writeDate ( std::ostream & os) const

Outputs the date on the std::ostream os, according to the locale imbued on the stream.

◆ writeTime()

std::ostream & RWDateTime::writeTime ( std::ostream & os) const

Outputs the time on the std::ostream os, according to the locale imbued on the stream.

◆ year()

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.

◆ yearGMT()

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.

Friends And Related Symbol Documentation

◆ operator!=()

bool operator!= ( const RWDateTime & d1,
const RWDateTime & d2 )
related

Returns true if d1 is not the same as d2.

◆ operator+ [1/2]

RWDateTime operator+ ( const RWDateTime & d,
rwint64 s )
friend

Returns the date s milliseconds in the future from the date d.

◆ operator+ [2/2]

RWDateTime operator+ ( rwint64 s,
const RWDateTime & d )
friend

Returns the date s milliseconds in the future from the date d.

◆ operator- [1/2]

RWDateTime operator- ( const RWDateTime & d,
rwint64 s )
friend

Returns the date s milliseconds in the past from d.

◆ operator- [2/2]

rwint64 operator- ( const RWDateTime & dt1,
const RWDateTime & dt2 )
friend

Returns the number of milliseconds between dt1 and dt2.

Exceptions
RWInternalErrThrown if either dt1 or dt2 is a sentinel.

◆ operator<()

bool operator< ( const RWDateTime & d1,
const RWDateTime & d2 )
related

Returns true if d1 is before d2.

◆ operator<<() [1/3]

RWFile & operator<< ( RWFile & file,
const RWDateTime & t )
related

Saves t to an RWFile.

◆ operator<<() [2/3]

RWvostream & operator<< ( RWvostream & str,
const RWDateTime & t )
related

Saves t to a virtual stream.

◆ operator<< [3/3]

std::ostream & operator<< ( std::ostream & s,
const RWDateTime & dt )
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.

Note
RWDateTime objects serialized via this function and restored using operator>>(std::istream&, RWDateTime&) are not guaranteed to roundtrip, and should not be used to persist date/time information. In order to persist RWDateTime objects such that they can be restored, see operator<<(RWvostream&, const RWDateTime&) and operator>>(RWvistream&, RWDateTime&).

◆ operator<=()

bool operator<= ( const RWDateTime & d1,
const RWDateTime & d2 )
related

Returns true if d1 is before or the same as d2.

◆ operator==()

bool operator== ( const RWDateTime & d1,
const RWDateTime & d2 )
related

Returns true if d1 is the same as d2.

◆ operator>()

bool operator> ( const RWDateTime & d1,
const RWDateTime & d2 )
related

Returns true if d1 is after d2.

◆ operator>=()

bool operator>= ( const RWDateTime & d1,
const RWDateTime & d2 )
related

Return true if d1 is after or the same as d2.

◆ operator>>() [1/5]

RWFile & operator>> ( RWFile & file,
RWDateTime & t )
related

Restores t from an RWFile, replacing the previous contents of t.

◆ operator>>() [2/5]

RWFile & operator>> ( RWFile & file,
RWDateTime *& t )
related

Restores an RWDateTime from an RWFile by allocating an RWDateTime on the heap and restoring its state.

◆ operator>>() [3/5]

RWvistream & operator>> ( RWvistream & str,
RWDateTime & t )
related

Restores t from a virtual stream, replacing the previous contents of t.

◆ operator>>() [4/5]

RWvistream & operator>> ( RWvistream & str,
RWDateTime *& t )
related

Restores an RWDateTime from a virtual stream by allocating an RWDateTime on the heap and restoring its state.

◆ operator>> [5/5]

std::istream & operator>> ( std::istream & s,
RWDateTime & dt )
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.

Note
RWDateTime objects serialized via operator<<(std::ostream&, const RWDateTime&) and restored using this function are not guaranteed to roundtrip, and should not be used to persist date/time information. In order to persist RWDateTime objects such that they can be restored, see operator<<(RWvostream&, const RWDateTime&) and operator>>(RWvistream&, RWDateTime&).

Member Data Documentation

◆ futureSentinel

const rwint64 RWDateTime::futureSentinel
static

Sentinel values representing future RWDateTime sentinels.

◆ invalidSentinel

const rwint64 RWDateTime::invalidSentinel
static

Sentinel values for invalid RWDateTime sentinels.

◆ maxDateTime

const rwint64 RWDateTime::maxDateTime
static

The maximum number of milliseconds that an RWDateTime may hold.

◆ millisecsInDay

const rwint64 RWDateTime::millisecsInDay
static

The number of milliseconds in a day.

◆ millisecsInHour

const rwint64 RWDateTime::millisecsInHour
static

The number of milliseconds in a hour.

◆ millisecsInMin

const rwint64 RWDateTime::millisecsInMin
static

The number of milliseconds in a minute.

◆ millisecsInSec

const rwint64 RWDateTime::millisecsInSec
static

The number of milliseconds in a second.

◆ minDateTime

const rwint64 RWDateTime::minDateTime
static

The minimum number of milliseconds that an RWDateTime may hold.

◆ nullSentinel

const rwint64 RWDateTime::nullSentinel
static

Sentinel values for null RWDateTime sentinels.

◆ pastSentinel

const rwint64 RWDateTime::pastSentinel
static

Sentinel values representing past RWDateTime sentinels.

◆ userSentinelStart

const rwint64 RWDateTime::userSentinelStart
static

The starting value for user-defined sentinels.

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