Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress C++ API Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

rwsf::DateTime


Does not inherit

Local Index

Members

Header File

#include rwsf/core/DateTime.h

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::DateTime is based on the Gregorian Calendar. The Gregorian calendar was introduced by Pope Gregory XIII in 1582, and was adopted in various places at various times. It was adopted by England on September 14, 1752, and thus came to the United States. rwsf::DateTime was designed for use with dates after September 14, 1752.

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

Note

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

The half day is subtracted so that the day starts at midnight in conformance with civil time reckoning.

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

Note that two-digit year specifiers assume the century 1900, so you will want to create programs that use four-digit year specifiers.

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

inttm_sec;

seconds after the minute - [0,59]

inttm_min;

minutes after the hour - [0,59]

inttm_hour;

hours since midnight - [0,23]

inttm_mday;

day of the month - [1,31]

inttm_mon;

months since January - [0,11]

inttm_year;

years since 1900

inttm_wday;

days since Sunday - [0,6]

inttm_yday;

days since January 1 - [0,365]

inttm_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:

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 hold 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 rwsf::DateTime whose value is not yet determined.

Public Enums

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

Public Constructors

DateTime(InitialState init_state = invalid);
DateTime(const DateTime & dt);
DateTime(rwsfint64 msec);
DateTime(const struct tm *,
    unsigned ms = 0,
    const rwsf::TimeZone & = rwsf::TimeZone::local());
DateTime(unsigned,
    const char * month,
    unsigned year,
    unsigned h,
    unsigned m,
    unsigned s,
    unsigned ms,
    const rwsf::Locale & loc = rwsf::Locale::global(),
    const rwsf::TimeZone & zone = rwsf::TimeZone::local());
DateTime(unsigned d,
    unsigned mo,
    unsigned y,
    unsigned h = 0,
    unsigned m = 0,
    unsigned s = 0,
    unsigned ms = 0,
    const rwsf::TimeZone & = 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());

Public Static Member Functions

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

Public Member Functions

std::string
asString(char format,
    const rwsf::Locale & loc = rwsf::Locale::global(),
    const rwsf::TimeZone & = rwsf::TimeZone::local()) const;
std::string
asString(const char * format,
    const rwsf::Locale & loc = rwsf::Locale::global(),
    const rwsf::TimeZone & = rwsf::TimeZone::local()) const;
std::string
asString(Format f,
    const rwsf::Locale & loc = rwsf::Locale::global(),
    const rwsf::TimeZone & = 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;
DateTime &
decrementHour(const rwsfint64 hour);
DateTime &
decrementMillisecond(const rwsfint64 millisecond);
DateTime &
decrementMinute(const rwsfint64 minute);
DateTime &
decrementSecond(const rwsfint64 second);
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;
DateTime &
incrementHour(const rwsfint64 hour);
DateTime &
incrementMillisecond(const rwsfint64 millisecond);
DateTime &
incrementMinute(const rwsfint64 minute);
DateTime &
incrementSecond(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;
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;

Public Operators

DateTime &
operator=(const DateTime & dt);


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.