HydraExpress™ C++ API Reference Guide

 
Loading...
Searching...
No Matches
rwsf::DateTime Class Reference

Represents a data and time as milliseconds from January 1, 1901 00:00:00:000 UTC. More...

#include <rwsf/core/DateTime.h>

Public Types

enum  Format { iso8601 , http }
enum  InitialState { invalid , null , setCurrentTime }
enum  SetType { setDate , setTime , setBoth }

Public Member Functions

 DateTime (const DateTime &dt)
 DateTime (const std::string &str, Format f, const rwsf::Locale &loc=rwsf::Locale::global(), const rwsf::TimeZone &zone=rwsf::TimeZone::local())
 DateTime (const std::string &str, SetType set_type=setBoth, const rwsf::Locale &loc=rwsf::Locale::global(), const rwsf::TimeZone &zone=rwsf::TimeZone::local())
 DateTime (const struct tm *, unsigned ms=0, const rwsf::TimeZone &zone=rwsf::TimeZone::local())
 DateTime (InitialState init_state=invalid)
 DateTime (std::int64_t msec)
 DateTime (unsigned day, const char *month, unsigned year, unsigned hour, unsigned minute, unsigned second, unsigned millisecond, const rwsf::Locale &loc=rwsf::Locale::global(), const rwsf::TimeZone &zone=rwsf::TimeZone::local())
 DateTime (unsigned day, unsigned month, unsigned year, unsigned hour=0, unsigned minute=0, unsigned second=0, unsigned millisecond=0, const rwsf::TimeZone &zone=rwsf::TimeZone::local())
std::string asString (char format, const rwsf::Locale &loc=rwsf::Locale::global(), const rwsf::TimeZone &zone=rwsf::TimeZone::local()) const
std::string asString (const char *format, const rwsf::Locale &loc=rwsf::Locale::global(), const rwsf::TimeZone &zone=rwsf::TimeZone::local()) const
std::string asString (Format f, const rwsf::Locale &loc=rwsf::Locale::global(), const rwsf::TimeZone &zone=rwsf::TimeZone::local()) const
bool between (const DateTime &a, const DateTime &b) const
int compareTo (const DateTime &d) const
int compareTo (const DateTime *d) const
unsigned correctedJulian () const
unsigned day (const rwsf::TimeZone &=rwsf::TimeZone::local()) const
unsigned dayGMT () const
unsigned dayOfMonth (const rwsf::TimeZone &=rwsf::TimeZone::local()) const
unsigned dayOfMonthGMT () const
DateTimedecrementHour (const std::int64_t hour)
DateTimedecrementMillisecond (const std::int64_t millisecond)
DateTimedecrementMinute (const std::int64_t minute)
DateTimedecrementSecond (const std::int64_t second)
bool empty () const
void extract (struct tm *tmbuf, const rwsf::TimeZone &zone=rwsf::TimeZone::local()) const
void extractGMT (struct tm *tmbuf) const
unsigned firstDayOfMonth (const rwsf::TimeZone &zone=rwsf::TimeZone::local()) const
unsigned firstDayOfMonth (unsigned mon, const rwsf::TimeZone &=rwsf::TimeZone::local()) const
unsigned hash () const
unsigned hour (const rwsf::TimeZone &=rwsf::TimeZone::local()) const
unsigned hourGMT () const
DateTimeincrementHour (const std::int64_t hour)
DateTimeincrementMillisecond (const std::int64_t millisecond)
DateTimeincrementMinute (const std::int64_t minute)
DateTimeincrementSecond (const std::int64_t second)
bool isDST (const rwsf::TimeZone &zone=rwsf::TimeZone::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 rwsf::TimeZone &zone=rwsf::TimeZone::local()) const
bool leapGMT () const
DateTime max (const DateTime &t) const
unsigned milliSecond () const
std::int64_t milliSeconds () const
DateTime min (const DateTime &t) const
unsigned minute (const rwsf::TimeZone &=rwsf::TimeZone::local()) const
unsigned minuteGMT () const
unsigned month (const rwsf::TimeZone &=rwsf::TimeZone::local()) const
unsigned monthGMT () const
std::string monthName (const rwsf::Locale &loc=rwsf::Locale::global(), const rwsf::TimeZone &=rwsf::TimeZone::local()) const
DateTime next (const char *dayName, const rwsf::Locale &loc=rwsf::Locale::global(), const rwsf::TimeZone &=rwsf::TimeZone::local()) const
DateTime next (unsigned dayNum, const rwsf::TimeZone &=rwsf::TimeZone::local()) const
DateTimeoperator= (const DateTime &dt)
DateTime previous (const char *dayName, const rwsf::Locale &loc=rwsf::Locale::global(), const rwsf::TimeZone &=rwsf::TimeZone::local()) const
DateTime previous (unsigned dayNum, const rwsf::TimeZone &=rwsf::TimeZone::local()) const
unsigned second () const
unsigned weekDay (const rwsf::TimeZone &=rwsf::TimeZone::local()) const
unsigned weekDayGMT () const
std::string weekDayName (const rwsf::Locale &loc=rwsf::Locale::global(), const rwsf::TimeZone &=rwsf::TimeZone::local()) const
unsigned year (const rwsf::TimeZone &=rwsf::TimeZone::local()) const
unsigned yearGMT () const

Static Public Member Functions

static DateTime beginDST (unsigned year, const rwsf::TimeZone &zone=rwsf::TimeZone::local())
static unsigned dayOfWeek (const char *day, const rwsf::Locale &loc=rwsf::Locale::global())
static unsigned daysInMonthYear (unsigned month, unsigned year)
static unsigned daysInYear (unsigned year)
static bool dayWithinMonth (unsigned mon, unsigned day, unsigned yr)
static DateTime endDST (unsigned year, const rwsf::TimeZone &zone=rwsf::TimeZone::local())
static unsigned hash (const DateTime &dt)
static unsigned indexOfMonth (const char *month, const rwsf::Locale &loc=rwsf::Locale::global())
static bool leapYear (unsigned year)
static std::string nameOfMonth (unsigned monthNum, const rwsf::Locale &loc=rwsf::Locale::global())
static DateTime now ()
static DateTime userSentinel (int i)
static std::string weekDayName (unsigned dayNum, const rwsf::Locale &loc=rwsf::Locale::global())

Static Public Attributes

static const std::int64_t futureSentinel
static const std::int64_t invalidSentinel
static const std::int64_t jday0
static const std::int64_t jul1901
static const std::int64_t maxDateTime
static const std::int64_t midnightJday0
static const std::int64_t midnightJul1901
static const std::int64_t millisecsInDay
static const std::int64_t millisecsInHour
static const std::int64_t millisecsInMin
static const std::int64_t millisecsInSec
static const std::int64_t minDateTime
static const std::int64_t nullSentinel
static const std::int64_t pastSentinel
static const std::int64_t userSentinelStart

Friends

DateTime operator+ (const DateTime &dt, std::int64_t ms)
DateTime operator+ (std::int64_t ms, const DateTime &dt)
DateTime operator- (const DateTime &dt, std::int64_t ms)
std::int64_t operator- (const DateTime &dt1, const DateTime &dt2)
bool operator< (const DateTime &t1, const DateTime &t2)
bool operator== (const DateTime &t1, const DateTime &t2)

(Note that these are not member symbols.)

bool operator!= (const DateTime &lhs, const DateTime &rhs)
bool operator<= (const DateTime &lhs, const DateTime &rhs)
bool operator> (const DateTime &lhs, const DateTime &rhs)
bool operator>= (const DateTime &lhs, const DateTime &rhs)

Detailed Description

Class rwsf::DateTime 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 std::int64_t.

rwsf::DateTime supports the ISO 8601 international standard for the formatting of dates and times.

rwsf::DateTimes can be converted to and from the Standard C Library type struct tm defined in <time.h>, and listed here.

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, which facilitates creating a large array, as follows:

// Creates an array with 5000 undefined dates and times
Represents a data and time as milliseconds from January 1, 1901 00:00:00:000 UTC.
Definition DateTime.h:160

rwsf::DateTime 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 it is applied to holds a sentinel value.

The use of the isValid() method does not definitively determine whether a member function can be successfully applied to an object since the null sentinel value represents a valid rwsf::DateTime whose value is not yet determined.

Two-digit year specifiers assume the century 1900. It is strongly recommended that you create programs that use four-digit year specifiers.

DateTime is primary used for dates based on the Gregorian Calendar.

Modified Julian Days

The modern Modified Julian Day (MJD) was introduced in the 1950's and starts at midnight, as opposed to the historic Julian Day (JD), which began at 12 noon. It 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.

Four public member functions, all starting with julian, let you manipulate the date via Modified Julian days (MJD). Note that the Modified Julian day number is not the same as a date according to the Julian calendar. The Modified Julian day number is calculated using Algorithm 199 from Communications of the ACM, Volume 6, No. 8, (Aug. 1963), p. 444 and is valid for any valid Gregorian date in the Gregorian calendar.

Modified Julian days in rwsf::DateTime operate correctly from Modified Julian day 0, but can only be converted to month, date, and year for Modified Julian days that fall within the Gregorian Calendar.

Member Enumeration Documentation

◆ Format

Specifies the format to be used for converting between an std::string and an rwsf::DateTime, using either the ISO 8601 standard, or HTTP specification date formats.

Enumerator
iso8601 

Convert using ISO 8601 standard format.

http 

Convert using HTTP specification format.

◆ InitialState

Specifies whether the constructor should construct an invalid, null, or current rwsf::DateTime. Default is to set an invalid rwsf::DateTime, with an undefined date and time.

Enumerator
invalid 

Constuct an invalid DataTime.

null 

Construct a null DataTime.

setCurrentTime 

Construct a DateTime from the current time.

◆ SetType

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

Enumerator
setDate 

Construct a DateTime with just a valid date.

setTime 

Construct a DateTime with just a valid time.

setBoth 

Construct a DateTime with a valid date and time.

Constructor & Destructor Documentation

◆ DateTime() [1/8]

rwsf::DateTime::DateTime ( InitialState init_state = invalid)

Default constructor. Constructs an rwsf::DateTime with undefined date and time. If init_state is set to DateTime::setCurrentTime, an instance with the current date and time is created. If init_state is set to DateTime::null, an instance set to null is created.

◆ DateTime() [2/8]

rwsf::DateTime::DateTime ( const DateTime & dt)

Copy constructor.

◆ DateTime() [3/8]

rwsf::DateTime::DateTime ( std::int64_t msec)
explicit

Constructs an rwsf::DateTime from the number of milliseconds since 1 January 1901 00:00:00:000 UTC. std::int64_t is at least a 64 bit integral type. msec may be negative for representing times prior to midnight 01/01/1901.

Note
This constructor must be passed an instance of a std::int64_t to ensure unambiguous construction.

For example, here is how to construct an rwsf::DateTime representing a time 230,375 milliseconds after midnight UTC on 01/01/1901:

rwsf::DateTime dt(std::int64_t(230375));

◆ DateTime() [4/8]

rwsf::DateTime::DateTime ( const struct tm * ,
unsigned ms = 0,
const rwsf::TimeZone & zone = rwsf::TimeZone::local() )

Constructs an rwsf::DateTime 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 rwsf::DateTime specified by ms. The components are understood to be relative to the time zone parameter zone, which defaults to local time. Note that while struct tm uses 0-based indexing for days of the week and months, rwsf::DateTime uses 1-based indexing for these two parameters. The arguments included in struct tm are shown above in the class description's table.

◆ DateTime() [5/8]

rwsf::DateTime::DateTime ( unsigned day,
const char * month,
unsigned year,
unsigned hour,
unsigned minute,
unsigned second,
unsigned millisecond,
const rwsf::Locale & loc = rwsf::Locale::global(),
const rwsf::TimeZone & zone = rwsf::TimeZone::local() )

Constructs an rwsf::DateTime using the specified day, month, year, hour, minute, second, and millisecond, all relative to the time zone parameter zone, which defaults to local time. The optional locale argument is used to convert the month name.

◆ DateTime() [6/8]

rwsf::DateTime::DateTime ( unsigned day,
unsigned month,
unsigned year,
unsigned hour = 0,
unsigned minute = 0,
unsigned second = 0,
unsigned millisecond = 0,
const rwsf::TimeZone & zone = rwsf::TimeZone::local() )

Constructs an rwsf::DateTime using the specified day, month, year, hour, minute, second, and millisecond, all relative to the time zone parameter zone, which defaults to local time.

◆ DateTime() [7/8]

rwsf::DateTime::DateTime ( const std::string & str,
SetType set_type = setBoth,
const rwsf::Locale & loc = rwsf::Locale::global(),
const rwsf::TimeZone & zone = rwsf::TimeZone::local() )
explicit

Converts the string str to a date and/or time as indicated by set_type, all relative to the time zone parameter zone, which defaults to local time. By default, both the date and time are set using locale loc. The constructor expects the date and time portions of the std::string to be separated by a semicolon when both date and time are being set. The locale argument is used to convert the month name. The member function isValid() must be used to test whether the results are a valid date. Because rwsf::Locale cannot rigorously check date input, dates created this way should also be reconfirmed by the user.

Example:

rwsf::DateTime("April 4, 1998; 10:00 am",
rwsf::Locale::global()); // sets date and time
rwsf::DateTime("April 4, 1998",
rwsf::Locale::global()); // sets date and
// initializes time to 00:00:00
rwsf::DateTime("10:00 am",
rwsf::Locale::global()); // initializes date to
// today at time 10:00
@ setTime
Construct a DateTime with just a valid time.
Definition DateTime.h:179
@ setBoth
Construct a DateTime with a valid date and time.
Definition DateTime.h:180
@ setDate
Construct a DateTime with just a valid date.
Definition DateTime.h:178
static const Locale & global()

◆ DateTime() [8/8]

rwsf::DateTime::DateTime ( const std::string & str,
Format f,
const rwsf::Locale & loc = rwsf::Locale::global(),
const rwsf::TimeZone & zone = rwsf::TimeZone::local() )

Constructs an rwsf::DateTime from the string str using the format specified by f. rwsf::DateTime currently supports the ISO 8601 format that is numeric and locale-neutral. As a result, the rwsf::Locale argument is ignored for ISO 8601, but is reserved for future use. The constructor uses the rwsf::TimeZone argument as a relative time zone offset unless the string specifies the UTC time zone or an offset from UTC, in which case the rwsf::TimeZone argument is ignored in favor of UTC.

Two Examples:

// Construct an rwsf::DateTime of 11:59:59 PM on December
// 24th,2001 in the rwsf::TimeZone::local() time zone.
rwsf::DateTime("2001-12-24T23:59:59",rwsf::DateTime::iso8601);
// Construct an rwsf::DateTime of 8 AM, April 12th, 1985 in
// the GMT time zone
rwsf::DateTime("1985-04-12T08:00:00Z", rwsf::DateTime::iso8601);
@ iso8601
Convert using ISO 8601 standard format.
Definition DateTime.h:189

For a date or time supplied singly (for example, "2001-12-24" or "23:59:59"), rwsf::DateTime calls the system to retrieve the current date or time.

Member Function Documentation

◆ asString() [1/3]

std::string rwsf::DateTime::asString ( char format,
const rwsf::Locale & loc = rwsf::Locale::global(),
const rwsf::TimeZone & zone = rwsf::TimeZone::local() ) const

Returns the date and time as a string, formatted by the optional locale argument, and relative to the time zone parameter zone. The function defaults to using the rwsf::Locale global locale.

Formats are as defined in the pre-1999 Standard C Library function strftime(), explained in the description for rwsf::Locale.

◆ asString() [2/3]

std::string rwsf::DateTime::asString ( const char * format,
const rwsf::Locale & loc = rwsf::Locale::global(),
const rwsf::TimeZone & zone = rwsf::TimeZone::local() ) const

Returns the date and time as a string, formatted by the optional locale argument, and relative to the time zone parameter zone. The function defaults to using the rwsf::Locale global locale.

Formats are as defined in the pre-1999 Standard C Library function strftime(), explained in the description for rwsf::Locale.

◆ asString() [3/3]

std::string rwsf::DateTime::asString ( Format f,
const rwsf::Locale & loc = rwsf::Locale::global(),
const rwsf::TimeZone & zone = rwsf::TimeZone::local() ) const

Returns the date and time as a string, using the specified format, and relative to the time zone parameter zone.

Currently supports the ISO 8601 format. This format is numeric and locale-neutral, and as such does not use the rwsf::Locale argument.

◆ beginDST()

DateTime rwsf::DateTime::beginDST ( unsigned year,
const rwsf::TimeZone & zone = rwsf::TimeZone::local() )
static

Returns the start of daylight saving time (DST) for the given year, in the given zone. If DST is not observed in that year and zone, still returns a time but an invalid one.

◆ between()

bool rwsf::DateTime::between ( const DateTime & a,
const DateTime & b ) const

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

◆ compareTo() [1/2]

int rwsf::DateTime::compareTo ( const DateTime & d) const

Compares self to the rwsf::DateTime referenced by d and returns:

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

◆ compareTo() [2/2]

int rwsf::DateTime::compareTo ( const DateTime * d) const

Compares self to the rwsf::DateTime pointed to by d and returns:

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

◆ correctedJulian()

unsigned rwsf::DateTime::correctedJulian ( ) const

Returns the value of the Julian day number. This value is one day less than the value of DateTime::julian() if the time is before noon UTC (GMT).

◆ day()

unsigned rwsf::DateTime::day ( const rwsf::TimeZone & = rwsf::TimeZone::local()) const

Returns the day of the year (1-366) for this date. The default for the optional time zone argument is local.

◆ dayGMT()

unsigned rwsf::DateTime::dayGMT ( ) const

Returns the day of the year (1-366) for this date relative to UTC (GMT).

◆ dayOfMonth()

unsigned rwsf::DateTime::dayOfMonth ( const rwsf::TimeZone & = rwsf::TimeZone::local()) const

Returns the day of the month (1-31) for this date. The default for the optional time zone argument is local.

◆ dayOfMonthGMT()

unsigned rwsf::DateTime::dayOfMonthGMT ( ) const

Returns the day of the month (1-31) for this date relative to UTC (GMT).

◆ dayOfWeek()

unsigned rwsf::DateTime::dayOfWeek ( const char * day,
const rwsf::Locale & loc = rwsf::Locale::global() )
static

Returns the number of the day of the week corresponding to the given day name, where Monday = 1, ..., Sunday = 7. Names are interpreted according to the optional loc argument. The method defaults to using the rwsf::Locale global locale.

◆ daysInMonthYear()

unsigned rwsf::DateTime::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()

unsigned rwsf::DateTime::daysInYear ( unsigned year)
static

Returns the number of days in a given year.

◆ dayWithinMonth()

bool rwsf::DateTime::dayWithinMonth ( unsigned mon,
unsigned day,
unsigned yr )
static

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

◆ decrementHour()

DateTime & rwsf::DateTime::decrementHour ( const std::int64_t hour)

Decrements the class's milliseconds data member by hour multiplied by DateTime::millisecsInHour, then returns self.

◆ decrementMillisecond()

DateTime & rwsf::DateTime::decrementMillisecond ( const std::int64_t millisecond)

Decrements the classes' milliseconds data member by millisecond, then returns self.

◆ decrementMinute()

DateTime & rwsf::DateTime::decrementMinute ( const std::int64_t minute)

Decrements the classes' milliseconds data member by minute multiplied by DateTime::millisecsInMin, then returns self.

◆ decrementSecond()

DateTime & rwsf::DateTime::decrementSecond ( const std::int64_t second)

Decrements the classes' milliseconds data member by second multiplied by DateTime::millisecsInSec, then returns self.

◆ empty()

bool rwsf::DateTime::empty ( ) const

Returns true if self is a null value.

◆ endDST()

DateTime rwsf::DateTime::endDST ( unsigned year,
const rwsf::TimeZone & zone = rwsf::TimeZone::local() )
static

Returns the end of daylight saving time (DST) for the given year, in the given zone. If DST is not observed in that year and zone, still returns a time but an invalid one.

◆ extract()

void rwsf::DateTime::extract ( struct tm * tmbuf,
const rwsf::TimeZone & zone = rwsf::TimeZone::local() ) const

Returns with the struct tm argument filled out completely. Note that while struct tm uses 0-based indexing for days of the week and months, rwsf::DateTime uses 1-based indexing for these two parameters. If the date is invalid, all fields are set to -1. The default for the optional time zone argument is local.

◆ extractGMT()

void rwsf::DateTime::extractGMT ( struct tm * tmbuf) const

Returns with the struct tm argument filled out completely, relative to UTC (GMT). Note that while struct tm uses 0-based indexing for days of the week and months, rwsf::DateTime uses 1-based indexing for these two parameters. If the date is invalid, all fields are set to -1. The default for the optional time zone argument is local.

◆ firstDayOfMonth() [1/2]

unsigned rwsf::DateTime::firstDayOfMonth ( const rwsf::TimeZone & zone = rwsf::TimeZone::local()) const

Returns the day of the year (1-366) corresponding to the first day of this rwsf::DateTime instance's month and year. The default for the optional time zone argument is local.

◆ firstDayOfMonth() [2/2]

unsigned rwsf::DateTime::firstDayOfMonth ( unsigned mon,
const rwsf::TimeZone & = rwsf::TimeZone::local() ) const

Returns the day of the year (1-366) corresponding to the first day of mon in this rwsf::DateTime instance's year. The default for the optional time zone argument is local.

◆ hash() [1/2]

unsigned rwsf::DateTime::hash ( ) const

Returns a suitable hashing value.

◆ hash() [2/2]

unsigned rwsf::DateTime::hash ( const DateTime & dt)
static

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

◆ hour()

unsigned rwsf::DateTime::hour ( const rwsf::TimeZone & = rwsf::TimeZone::local()) const

Returns the hour relative to the time zone specified. The default for the optional time zone argument is local.

◆ hourGMT()

unsigned rwsf::DateTime::hourGMT ( ) const

Returns the hour relative to UTC (GMT).

◆ incrementHour()

DateTime & rwsf::DateTime::incrementHour ( const std::int64_t hour)

Increments the class' milliseconds data member by hour times DateTime::millisecsInHour, then returns self.

◆ incrementMillisecond()

DateTime & rwsf::DateTime::incrementMillisecond ( const std::int64_t millisecond)

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

◆ incrementMinute()

DateTime & rwsf::DateTime::incrementMinute ( const std::int64_t minute)

Increments the classes' milliseconds data member by minute multiplied by DateTime::millisecsInMin, then returns self.

◆ incrementSecond()

DateTime & rwsf::DateTime::incrementSecond ( const std::int64_t second)

Increments the classes' milliseconds data member by second multiplied by DateTime::millisecsInSec, then returns self.

◆ indexOfMonth()

unsigned rwsf::DateTime::indexOfMonth ( const char * month,
const rwsf::Locale & loc = rwsf::Locale::global() )
static

Returns a number between 1 and 12 corresponding to the given month name. Returns 0 for no match. Months are interpreted based on the optional loc argument. The method defaults to using the rwsf::Locale global locale.

◆ isDST()

bool rwsf::DateTime::isDST ( const rwsf::TimeZone & zone = rwsf::TimeZone::local()) const

Returns true if self is during daylight saving time in the time zone given by zone, false otherwise.

◆ isFuture()

bool rwsf::DateTime::isFuture ( ) const

Returns true if self is a future sentinel.

◆ isInvalid()

bool rwsf::DateTime::isInvalid ( ) const

Returns true if self is an invalid sentinel.

◆ isNull()

bool rwsf::DateTime::isNull ( ) const

Returns true if self is a null sentinel.

◆ isPast()

bool rwsf::DateTime::isPast ( ) const

Returns true if self is a past sentinel.

◆ isSentinel()

bool rwsf::DateTime::isSentinel ( ) const

Returns true if self is a sentinel of any kind.

◆ isValid()

bool rwsf::DateTime::isValid ( ) const

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

◆ julian() [1/2]

unsigned rwsf::DateTime::julian ( ) const

Returns the value of the Modified Julian day number.

◆ julian() [2/2]

void rwsf::DateTime::julian ( unsigned j)

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

◆ julianDay() [1/2]

double rwsf::DateTime::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.

Note
The example values are computed using Greenwich meridian. A different time zone would change the result of julianDay().

◆ julianDay() [2/2]

void rwsf::DateTime::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.

Note
The example values are for an rwsf::DateTime instance set to the Greenwich meridian. The results would be different for rwsf::DateTime instances set to a different time zone.

◆ leap()

bool rwsf::DateTime::leap ( const rwsf::TimeZone & zone = rwsf::TimeZone::local()) const

Returns true if self is a leap year relative to the rwsf::TimeZone argument.

◆ leapGMT()

bool rwsf::DateTime::leapGMT ( ) const

Returns true if self is a leap year relative to UTC (GMT).

◆ leapYear()

bool rwsf::DateTime::leapYear ( unsigned year)
static

Returns true if a given year is a leap year.

◆ max()

DateTime rwsf::DateTime::max ( const DateTime & t) const

Returns the later rwsf::DateTime of self or t.

◆ milliSecond()

unsigned rwsf::DateTime::milliSecond ( ) const

Returns the millisecond part of self.

◆ milliSeconds()

std::int64_t rwsf::DateTime::milliSeconds ( ) const

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

◆ min()

DateTime rwsf::DateTime::min ( const DateTime & t) const

Returns the earlier rwsf::DateTime of self or t.

◆ minute()

unsigned rwsf::DateTime::minute ( const rwsf::TimeZone & = rwsf::TimeZone::local()) const

Returns the minute of self, adjusted to the time zone specified.

◆ minuteGMT()

unsigned rwsf::DateTime::minuteGMT ( ) const

Returns the minute of self relative to UTC (GMT).

◆ month()

unsigned rwsf::DateTime::month ( const rwsf::TimeZone & = rwsf::TimeZone::local()) const

Returns the month (1-12) for this date. The default for the optional time zone argument is local.

◆ monthGMT()

unsigned rwsf::DateTime::monthGMT ( ) const

Returns the month (1-12) for this date relative to UTC (GMT).

◆ monthName()

std::string rwsf::DateTime::monthName ( const rwsf::Locale & loc = rwsf::Locale::global(),
const rwsf::TimeZone & = rwsf::TimeZone::local() ) const

Returns the name of the month for this date, according to the optional locale argument. The method defaults to using the rwsf::Locale global locale.

◆ nameOfMonth()

std::string rwsf::DateTime::nameOfMonth ( unsigned monthNum,
const rwsf::Locale & loc = rwsf::Locale::global() )
static

Returns the name of the month for monthNum, where January = 1, ..., December = 12. Months are interpreted based on the optional loc argument. The method defaults to using the rwsf::Locale global locale.

◆ next() [1/2]

DateTime rwsf::DateTime::next ( const char * dayName,
const rwsf::Locale & loc = rwsf::Locale::global(),
const rwsf::TimeZone & = rwsf::TimeZone::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.

◆ next() [2/2]

DateTime rwsf::DateTime::next ( unsigned dayNum,
const rwsf::TimeZone & = rwsf::TimeZone::local() ) const

Returns the date of the next day of the week, where Monday = 1, ..., Sunday = 7. The parameter dayNum must be between 1 and 7, inclusive. The default for the optional time zone argument is local.

◆ now()

DateTime rwsf::DateTime::now ( )
static

Returns current date and time.

◆ operator=()

DateTime & rwsf::DateTime::operator= ( const DateTime & dt)

Assignment operator.

◆ previous() [1/2]

DateTime rwsf::DateTime::previous ( const char * dayName,
const rwsf::Locale & loc = rwsf::Locale::global(),
const rwsf::TimeZone & = rwsf::TimeZone::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 method defaults to using the rwsf::Locale global locale.

◆ previous() [2/2]

DateTime rwsf::DateTime::previous ( unsigned dayNum,
const rwsf::TimeZone & = rwsf::TimeZone::local() ) const

Returns the date of the previous numbered day of the week, where Monday = 1, ..., Sunday = 7. The parameter dayNum must be between 1and 7, inclusive. The default for the optional time zone argument is local.

◆ second()

unsigned rwsf::DateTime::second ( ) const

Returns the seconds part of self.

Note
This value does not vary depending on the time zone.

◆ userSentinel()

DateTime rwsf::DateTime::userSentinel ( int i)
static

Returns user-defined sentinel number i. Throws rwsf::OutOfBoundsException if the parameter is outside the range 0 to 127.

◆ weekDay()

unsigned rwsf::DateTime::weekDay ( const rwsf::TimeZone & = rwsf::TimeZone::local()) const

Returns the number of the day of the week for this date, where Monday = 1, ..., Sunday = 7.

◆ weekDayGMT()

unsigned rwsf::DateTime::weekDayGMT ( ) const

Returns the number of the day of the week for this date relative to UTC (GMT).

◆ weekDayName() [1/2]

std::string rwsf::DateTime::weekDayName ( const rwsf::Locale & loc = rwsf::Locale::global(),
const rwsf::TimeZone & = rwsf::TimeZone::local() ) const

Returns the name of the day of the week for this date, according to the optional locale argument. The method defaults to using the rwsf::Locale global locale.

◆ weekDayName() [2/2]

std::string rwsf::DateTime::weekDayName ( unsigned dayNum,
const rwsf::Locale & loc = rwsf::Locale::global() )
static

Returns the name of the day of the week for dayNum, where Monday = 1, ..., Sunday = 7. Days are interpreted based on the optional loc argument. The method defaults to using the rwsf::Locale global locale.

◆ year()

unsigned rwsf::DateTime::year ( const rwsf::TimeZone & = rwsf::TimeZone::local()) const

Returns the year of self. The default for the optional time zone argument is local.

◆ yearGMT()

unsigned rwsf::DateTime::yearGMT ( ) const

Returns the year of self relative to UTC (GMT).

◆ operator!=()

bool operator!= ( const DateTime & lhs,
const DateTime & rhs )
related

Returns true if lhs is not the same as rhs.

◆ operator+ [1/2]

DateTime operator+ ( const DateTime & dt,
std::int64_t ms )
friend

Returns the date ms milliseconds in the future from the date dt.

◆ operator+ [2/2]

DateTime operator+ ( std::int64_t ms,
const DateTime & dt )
friend

Returns the date ms milliseconds in the future from the date dt.

◆ operator- [1/2]

DateTime operator- ( const DateTime & dt,
std::int64_t ms )
friend

Returns the date ms milliseconds in the past from dt.

◆ operator- [2/2]

std::int64_t operator- ( const DateTime & dt1,
const DateTime & dt2 )
friend

Returns the number of milliseconds between dt1 and dt2.

◆ operator<

bool operator< ( const DateTime & t1,
const DateTime & t2 )
friend

Returns true if t1 is before t2.

◆ operator<=()

bool operator<= ( const DateTime & lhs,
const DateTime & rhs )
related

Returns true if lhs is before or the same as rhs.

◆ operator==

bool operator== ( const DateTime & t1,
const DateTime & t2 )
friend

Returns true if t1 is the same as t2.

◆ operator>()

bool operator> ( const DateTime & lhs,
const DateTime & rhs )
related

Returns true if lhs is after rhs.

◆ operator>=()

bool operator>= ( const DateTime & lhs,
const DateTime & rhs )
related

Return true if lhs is after or the same as rhs.

Member Data Documentation

◆ futureSentinel

const std::int64_t rwsf::DateTime::futureSentinel
static

Sentinel values representing future rwsf::DateTime instances.

◆ invalidSentinel

const std::int64_t rwsf::DateTime::invalidSentinel
static

Sentinel values for invalid rwsf::DateTime sentinels.

◆ jday0

const std::int64_t rwsf::DateTime::jday0
static

The millisecond count at noon on Julian day zero.

◆ jul1901

const std::int64_t rwsf::DateTime::jul1901
static

Julian Day Number for noon 1/1/1901.

◆ maxDateTime

const std::int64_t rwsf::DateTime::maxDateTime
static

The maximum number of milliseconds that an rwsf::DateTime may hold.

◆ midnightJday0

const std::int64_t rwsf::DateTime::midnightJday0
static

The millisecond count at midnight on Julian day zero.

◆ midnightJul1901

const std::int64_t rwsf::DateTime::midnightJul1901
static

Julian Day Number for midnight 1/1/1901.

◆ millisecsInDay

const std::int64_t rwsf::DateTime::millisecsInDay
static

The number of milliseconds in a day.

◆ millisecsInHour

const std::int64_t rwsf::DateTime::millisecsInHour
static

The number of milliseconds in a hour.

◆ millisecsInMin

const std::int64_t rwsf::DateTime::millisecsInMin
static

The number of milliseconds in a minute.

◆ millisecsInSec

const std::int64_t rwsf::DateTime::millisecsInSec
static

The number of milliseconds in a second.

◆ minDateTime

const std::int64_t rwsf::DateTime::minDateTime
static

The minimum number of milliseconds that an rwsf::DateTime may hold.

◆ nullSentinel

const std::int64_t rwsf::DateTime::nullSentinel
static

Sentinel values for null rwsf::DateTime sentinels.

◆ pastSentinel

const std::int64_t rwsf::DateTime::pastSentinel
static

Sentinel values representing past rwsf::DateTime instances.

◆ userSentinelStart

const std::int64_t rwsf::DateTime::userSentinelStart
static

The starting value for user-defined sentinels.

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