OWLNext 7.0
Borland's Object Windows Library for the modern age
|
The TDate class represents a date. More...
#include <owl/date.h>
Public Types | |
enum | HowToPrint { Normal , Terse , Numbers , EuropeanNumbers , European , WinIntSection } |
Lists different print formats. More... | |
enum | TDateType { dtMonthNames , dtUCMonthNames , dtWeekDayNames , dtUCWeekDayNames } |
Public Member Functions | |
TDate () | |
Construct a TDate with the current date. | |
TDate (DayTy day, YearTy year) | |
Construct a TDate with a given day of the year and a given year. | |
TDate (DayTy, const tstring &month, YearTy) | |
Construct a TDate for the given day, month, and year. | |
TDate (DayTy, MonthTy, YearTy) | |
Construct a TDate for the given day, month, and year. | |
TDate (const tistream &s) | |
Read date from stream. | |
TDate (const TTime &) | |
Construct a TDate from a TTime. | |
TDate (const TSystemTime &) | |
Construct a TDate from a TSystemTime. | |
TDate (LPCTSTR str, LPCTSTR format=nullptr) | |
TDate (const tstring &s) | |
TDate (const tstring &s, const tstring &format) | |
TSystemTime | GetSystemTime () const |
tstring | AsString () const |
Converts the TDate object to a string object. | |
int | Between (const TDate &d1, const TDate &d2) const |
Returns 1 if this TDate object is between d1 and d2, inclusive. | |
int | CompareTo (const TDate &) const |
Returns 1 if the target TDate is greater than parameter TDate, -1 if the target is less than the parameter, and 0 if the dates are equal. | |
DayTy | Day () const |
Returns the day of the year (1-365). | |
int | DaysInMonth (MonthTy month=0) const |
DayTy | DayOfMonth () const |
Returns the day (1-31) of the month of this TDate. | |
DayTy | FirstDayOfMonth () const |
Returns the number of the first day of the month for this TDate. | |
DayTy | FirstDayOfMonth (MonthTy) const |
Return the number of the first day of a given month Return 0 if "month" is outside of the range 1 through 12, inclusive. | |
unsigned | Hash () const |
Returns a hash value for the date. | |
int | IsValid () const |
Returns 1 if this TDate is valid, 0 otherwise. | |
int | Leap () const |
leap year? | |
TDate | Max (const TDate &dt) const |
Compares this TDate with dt and returns the date with the greater Julian number. | |
TDate | Min (const TDate &dt) const |
Compares this TDate with dt and returns the date with the lesser Julian number. | |
MonthTy | Month () const |
Returns the month of this TDate. | |
LPCTSTR | NameOfDay () const |
Returns this TDate's day string name. | |
LPCTSTR | NameOfMonth () const |
Returns this TDate's month string name. | |
TDate | Previous (const tstring &dayName) const |
Return date of previous dayName. | |
TDate | Previous (DayTy) const |
Same as above, but use day of week. | |
DayTy | WeekDay (DayTy day=0) const |
Returns 1 (Monday) through 7 (Sunday). | |
YearTy | Year () const |
Returns the year of this TDate. | |
int | operator< (const TDate &date) const |
Returns 1 if this TDate precedes date. Otherwise returns 0. | |
int | operator<= (const TDate &date) const |
Returns 1 if this TDate is less than or equal to date, otherwise returns 0. | |
int | operator> (const TDate &date) const |
Returns 1 if this TDate is greater than date. otherwise returns 0. | |
int | operator>= (const TDate &date) const |
Returns 1 if this TDate is greater than or equal to date, otherwise returns 0. | |
int | operator== (const TDate &date) const |
Returns 1 if this TDate is equal to date, otherwise returns 0. | |
int | operator!= (const TDate &date) const |
Returns 1 if this TDate is not equal to date, otherwise returns 0. | |
JulTy | operator- (const TDate &dt) const |
Subtracts dt from this TDate and returns the difference. | |
void | operator++ () |
Increments this TDate by 1. | |
void | operator-- () |
Decrements this TDate by 1. | |
void | operator+= (int dd) |
Adds dd to this TDate. | |
void | operator-= (int dd) |
Subtracts dd from this TDate. | |
Static Public Member Functions | |
static LPCTSTR | DayName (DayTy weekDayNumber) |
Returns a string name for the weekday number. | |
static DayTy | DayOfWeek (const tstring &dayName) |
Return the number, 1-7, of the day of the week named nameOfDay. | |
static int | DayWithinMonth (MonthTy, DayTy, YearTy) |
Returns 1 if the given day (1-31) is within the given month for the given year. | |
static DayTy | DaysInYear (YearTy) |
Returns the number of days in the year specified (365 or 366). | |
static MonthTy | IndexOfMonth (const tstring &monthName) |
Returns the number, 1-12, of the month named nameOfMonth. | |
static JulTy | Jday (MonthTy, DayTy, YearTy) |
Convert Gregorian calendar date to the corresponding Julian day number j. | |
static int | LeapYear (YearTy year) |
static LPCTSTR | MonthName (MonthTy monthNumber) |
Returns the string name for the given monthNumber (1-12). | |
static HowToPrint | SetPrintOption (HowToPrint h) |
Sets the print option for all TDate objects and returns the old setting. | |
static void | SetIntlNames (TDateType type, const tchar **names) |
static const tchar * | GetIntlName (TDateType type, int index) |
Static Protected Member Functions | |
static int | AssertWeekDayNumber (DayTy d) |
Returns 1 if d is between 1 and 7 inclusive, otherwise returns 0. | |
static int | AssertIndexOfMonth (MonthTy m) |
Returns 1 if m is between 1 and 12 inclusive, otherwise returns 0. | |
Friends | |
TDate | operator+ (const TDate &dt, int dd) |
Returns a new TDate containing the sum of this TDate and dd. | |
TDate | operator+ (int dd, const TDate &dt) |
Returns a new TDate containing the sum of this TDate and dd. | |
TDate | operator- (const TDate &dt, int dd) |
tostream & | operator<< (tostream &s, const TDate &d) |
Inserts date into output stream os. | |
tistream & | operator>> (tistream &s, TDate &d) |
Extracts date from input stream is. | |
opstream & | operator<< (opstream &s, const TDate &d) |
ipstream & | operator>> (ipstream &s, TDate &d) |
The TDate class represents a date.
It has members that read, write, and store dates, and that convert dates to Gregorian calendar dates.
owl::TDate::TDate | ( | ) |
Construct a TDate with a given day of the year and a given year.
Constructs a TDate object with the given day and year.
The base date for this computation is Dec. 31 of the previous year. If year == 0, Construct a TDate with Jan. 1, 1901 as the "day zero". i.e., TDate(-1,0) = Dec. 31, 1900 and TDate(1,0) = Jan. 2, 1901.
The base date for this computation is December 31 of the previous year. If year == 0, it constructs a TDate with January 1, 1901, as the "day zero." For example, TDate(-1,0) = December 31, 1900, and TDate(1,0) = January 2, 1901.
Definition at line 84 of file date.cpp.
References Jday().
|
inline |
owl::TDate::TDate | ( | const TTime & | t | ) |
Construct a TDate from a TTime.
Type conversion to date.
Definition at line 111 of file date.cpp.
References owl::TTime::IsValid(), and owl::SECONDS_IN_DAY.
owl::TDate::TDate | ( | const TSystemTime & | t | ) |
Construct a TDate from a TSystemTime.
Definition at line 119 of file date.cpp.
References owl::TSystemTime::GetDay(), owl::TSystemTime::GetMonth(), owl::TSystemTime::GetYear(), and Jday().
tstring owl::TDate::AsString | ( | ) | const |
Converts the TDate object to a string object.
Definition at line 29 of file dateio.cpp.
DayTy owl::TDate::Day | ( | ) | const |
Returns a string name for the weekday number.
Monday == 1, ... , Sunday == 7 Return 0 for weekday number out of range
Definition at line 146 of file date.cpp.
References AssertWeekDayNumber().
DayTy owl::TDate::DayOfMonth | ( | ) | const |
Return the number, 1-7, of the day of the week named nameOfDay.
Return 0 if name doesn't match.
Definition at line 155 of file date.cpp.
References owl::FindMatch().
Definition at line 162 of file date.cpp.
References AssertIndexOfMonth(), Leap(), and Month().
Returns the number of days in the year specified (365 or 366).
Definition at line 194 of file date.cpp.
References LeapYear().
Returns 1 if the given day (1-31) is within the given month for the given year.
Definition at line 181 of file date.cpp.
References AssertIndexOfMonth(), and LeapYear().
|
inline |
Returns the number of the first day of the month for this TDate.
Definition at line 206 of file date.h.
References FirstDayOfMonth(), and Month().
Return the number of the first day of a given month Return 0 if "month" is outside of the range 1 through 12, inclusive.
Definition at line 311 of file date.cpp.
References AssertIndexOfMonth(), and Leap().
TSystemTime owl::TDate::GetSystemTime | ( | ) | const |
unsigned owl::TDate::Hash | ( | ) | const |
Returns the number, 1-12, of the month named nameOfMonth.
Return 0 for no match.
Definition at line 203 of file date.cpp.
References owl::FindMatch().
|
inline |
Convert Gregorian calendar date to the corresponding Julian day number j.
Algorithm 199 from Communications of the ACM, Volume 6, No. 8, (Aug. 1963), p. 444. Gregorian calendar started on Sep. 14, 1752. This function not valid before that. Returns 0 if the date is invalid.
Definition at line 215 of file date.cpp.
References DayWithinMonth().
|
inline |
leap year?
Returns 1 if this TDate's year is a leap year, 0 otherwise.
Definition at line 218 of file date.h.
References LeapYear(), and Year().
MonthTy owl::TDate::Month | ( | ) | const |
Returns the string name for the given monthNumber (1-12).
Returns 0 for an invalid monthNumber.
Definition at line 249 of file date.cpp.
References AssertIndexOfMonth().
|
inline |
|
inline |
Returns this TDate's month string name.
Definition at line 230 of file date.h.
References Month(), and MonthName().
|
inline |
|
inline |
Return date of previous dayName.
Returns the TDate of the previous dayName.
Definition at line 390 of file date.cpp.
References DayOfWeek(), and Previous().
|
static |
Sets the print option for all TDate objects and returns the old setting.
Definition at line 39 of file dateio.cpp.
YearTy owl::TDate::Year | ( | ) | const |
Inserts date into output stream os.
Definition at line 184 of file dateio.cpp.
Extracts date from input stream is.
Definition at line 240 of file dateio.cpp.