HydraExpress™ C++ API Reference Guide

Product Documentation:
   HydraExpress C++
Documentation Home
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | Related Functions
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 (InitialState init_state=invalid)
 
 DateTime (const DateTime &dt)
 
 DateTime (rwsfint64 msec)
 
 DateTime (const struct tm *, unsigned ms=0, const rwsf::TimeZone &zone=rwsf::TimeZone::local())
 
 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())
 
 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 std::string &str, Format f, const rwsf::Locale &loc=rwsf::Locale::global(), 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 rwsfint64 hour)
 
DateTimedecrementMillisecond (const rwsfint64 millisecond)
 
DateTimedecrementMinute (const rwsfint64 minute)
 
DateTimedecrementSecond (const rwsfint64 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 (unsigned mon, const rwsf::TimeZone &=rwsf::TimeZone::local()) const
 
unsigned firstDayOfMonth (const rwsf::TimeZone &zone=rwsf::TimeZone::local()) const
 
unsigned hash () const
 
unsigned hour (const rwsf::TimeZone &=rwsf::TimeZone::local()) const
 
unsigned hourGMT () const
 
DateTimeincrementHour (const rwsfint64 hour)
 
DateTimeincrementMillisecond (const rwsfint64 millisecond)
 
DateTimeincrementMinute (const rwsfint64 minute)
 
DateTimeincrementSecond (const rwsfint64 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
 
rwsfint64 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 (unsigned dayNum, 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
 
DateTimeoperator= (const DateTime &dt)
 
DateTime previous (unsigned dayNum, const rwsf::TimeZone &=rwsf::TimeZone::local()) const
 
DateTime previous (const char *dayName, const rwsf::Locale &loc=rwsf::Locale::global(), 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 rwsfint64 futureSentinel
 
static const rwsfint64 invalidSentinel
 
static const rwsfint64 jday0
 
static const rwsfint64 jul1901
 
static const rwsfint64 maxDateTime
 
static const rwsfint64 midnightJday0
 
static const rwsfint64 midnightJul1901
 
static const rwsfint64 millisecsInDay
 
static const rwsfint64 millisecsInHour
 
static const rwsfint64 millisecsInMin
 
static const rwsfint64 millisecsInSec
 
static const rwsfint64 minDateTime
 
static const rwsfint64 nullSentinel
 
static const rwsfint64 pastSentinel
 
static const rwsfint64 userSentinelStart
 

Friends

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

Related Functions

(Note that these are not member functions.)

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 rwsfint64.

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

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

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.

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.

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

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.

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

Copy constructor.

rwsf::DateTime::DateTime ( rwsfint64  msec)
explicit

Constructs an rwsf::DateTime from the number of milliseconds since 1 January 1901 00:00:00:000 UTC. rwsfint64 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 rwsfint64 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(rwsfint64(230375));
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.

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.

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.

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

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

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.

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.

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.

static 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.

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

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

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

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.

unsigned rwsf::DateTime::dayGMT ( ) const

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

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.

unsigned rwsf::DateTime::dayOfMonthGMT ( ) const

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

static 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.

static 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.

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

Returns the number of days in a given year.

static 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.

DateTime& rwsf::DateTime::decrementHour ( const rwsfint64  hour)

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

DateTime& rwsf::DateTime::decrementMillisecond ( const rwsfint64  millisecond)

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

DateTime& rwsf::DateTime::decrementMinute ( const rwsfint64  minute)

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

DateTime& rwsf::DateTime::decrementSecond ( const rwsfint64  second)

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

bool rwsf::DateTime::empty ( ) const

Returns true if self is a null value.

static 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.

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.

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.

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.

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.

unsigned rwsf::DateTime::hash ( ) const

Returns a suitable hashing value.

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

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

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.

unsigned rwsf::DateTime::hourGMT ( ) const

Returns the hour relative to UTC (GMT).

DateTime& rwsf::DateTime::incrementHour ( const rwsfint64  hour)

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

DateTime& rwsf::DateTime::incrementMillisecond ( const rwsfint64  millisecond)

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

DateTime& rwsf::DateTime::incrementMinute ( const rwsfint64  minute)

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

DateTime& rwsf::DateTime::incrementSecond ( const rwsfint64  second)

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

static 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.

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.

bool rwsf::DateTime::isFuture ( ) const

Returns true if self is a future sentinel.

bool rwsf::DateTime::isInvalid ( ) const

Returns true if self is an invalid sentinel.

bool rwsf::DateTime::isNull ( ) const

Returns true if self is a null sentinel.

bool rwsf::DateTime::isPast ( ) const

Returns true if self is a past sentinel.

bool rwsf::DateTime::isSentinel ( ) const

Returns true if self is a sentinel of any kind.

bool rwsf::DateTime::isValid ( ) const

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

unsigned rwsf::DateTime::julian ( ) const

Returns the value of the Modified Julian day number.

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

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

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

bool rwsf::DateTime::leapGMT ( ) const

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

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

Returns true if a given year is a leap year.

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

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

unsigned rwsf::DateTime::milliSecond ( ) const

Returns the millisecond part of self.

rwsfint64 rwsf::DateTime::milliSeconds ( ) const

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

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

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

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

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

unsigned rwsf::DateTime::minuteGMT ( ) const

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

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.

unsigned rwsf::DateTime::monthGMT ( ) const

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

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.

static 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.

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.

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.

static DateTime rwsf::DateTime::now ( )
static

Returns current date and time.

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

Assignment operator.

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.

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.

unsigned rwsf::DateTime::second ( ) const

Returns the seconds part of self.

Note
This value does not vary depending on the time zone.
static 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.

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.

unsigned rwsf::DateTime::weekDayGMT ( ) const

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

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.

static 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.

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.

unsigned rwsf::DateTime::yearGMT ( ) const

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

Friends And Related Function Documentation

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

Returns true if lhs is not the same as rhs.

DateTime operator+ ( const DateTime dt,
rwsfint64  ms 
)
friend

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

DateTime operator+ ( rwsfint64  ms,
const DateTime dt 
)
friend

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

DateTime operator- ( const DateTime dt,
rwsfint64  ms 
)
friend

Returns the date ms milliseconds in the past from dt.

rwsfint64 operator- ( const DateTime dt1,
const DateTime dt2 
)
friend

Returns the number of milliseconds between dt1 and dt2.

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

Returns true if t1 is before t2.

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

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

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

Returns true if t1 is the same as t2.

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

Returns true if lhs is after rhs.

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

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

Member Data Documentation

const rwsfint64 rwsf::DateTime::futureSentinel
static

Sentinel values representing future rwsf::DateTime instances.

const rwsfint64 rwsf::DateTime::invalidSentinel
static

Sentinel values for invalid rwsf::DateTime sentinels.

const rwsfint64 rwsf::DateTime::jday0
static

The millisecond count at noon on Julian day zero.

const rwsfint64 rwsf::DateTime::jul1901
static

Julian Day Number for noon 1/1/1901.

const rwsfint64 rwsf::DateTime::maxDateTime
static

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

const rwsfint64 rwsf::DateTime::midnightJday0
static

The millisecond count at midnight on Julian day zero.

const rwsfint64 rwsf::DateTime::midnightJul1901
static

Julian Day Number for midnight 1/1/1901.

const rwsfint64 rwsf::DateTime::millisecsInDay
static

The number of milliseconds in a day.

const rwsfint64 rwsf::DateTime::millisecsInHour
static

The number of milliseconds in a hour.

const rwsfint64 rwsf::DateTime::millisecsInMin
static

The number of milliseconds in a minute.

const rwsfint64 rwsf::DateTime::millisecsInSec
static

The number of milliseconds in a second.

const rwsfint64 rwsf::DateTime::minDateTime
static

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

const rwsfint64 rwsf::DateTime::nullSentinel
static

Sentinel values for null rwsf::DateTime sentinels.

const rwsfint64 rwsf::DateTime::pastSentinel
static

Sentinel values representing past rwsf::DateTime instances.

const rwsfint64 rwsf::DateTime::userSentinelStart
static

The starting value for user-defined sentinels.

Copyright © 2019 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is registered trademark of Rogue Wave Software, Inc. in the United States and other countries, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.