#include <lkdatetime.h>
Inheritance diagram for look::LookDate::
Public Methods | |
LookDate (unsigned long julianDate=0UL) | |
Constructor. More... | |
LookDate (const LookDate &theOther) | |
Copy constructor. | |
LookDate (unsigned int theDay, unsigned int theMonth, unsigned int theYear) | |
Constructor. More... | |
LookDate (unsigned int theDay, const LookString &theMonth, unsigned int theYear) | |
Constructor. More... | |
~LookDate (void) | |
Destructor. | |
LookTypeBase* | GetNewCopy (void) const |
Get a new copy. More... | |
long | GetTypeID (void) const |
Get Type ID. More... | |
LookDate& | operator++ () |
Prefix ++. Add one day. | |
LookDate | operator++ (int) |
Postfix ++. Add one day. | |
LookDate& | operator-- () |
Prefix --. Subtract one day. | |
LookDate | operator-- (int) |
Postfix --. Subtract one day. | |
LookDate& | operator+= (long theDays) |
Add days to self. More... | |
LookDate | operator+ (long theDays) const |
Add days. More... | |
LookDate& | operator-= (long theDays) |
Subtract days from self. More... | |
LookDate | operator- (long theDays) const |
Subtract days from self. More... | |
long | operator- (const LookDate &theDate) const |
Days between two dates. More... | |
void | AddMonths (int theMonths) |
Add Months. | |
bool | operator== (const LookDate &theOther) const |
Equal. | |
bool | operator!= (const LookDate &theOther) const |
Not equal. | |
bool | operator< (const LookDate &theOther) const |
Less than. | |
bool | operator> (const LookDate &theOther) const |
Greater than. | |
bool | operator<= (const LookDate &theOther) const |
Less than or equal. | |
bool | operator>= (const LookDate &theOther) const |
Greater than or equal. | |
bool | IsSet (void) const |
Is the date set? More... | |
unsigned int | DayOfMonth (void) const |
Day of the month (1-31). | |
unsigned int | Month (void) const |
Month of the year(1-12, 1 = January). | |
unsigned int | Year (void) const |
Year. | |
unsigned int | DayOfYear (void) const |
Day in year (1-366). | |
unsigned int | DayOfWeek (void) const |
Day in week (1-7, 1 = Monday). | |
LookString | DayName (void) const |
Day as string ("Monday"). | |
LookString | MonthName (void) const |
Month as string ("March"). | |
LookDate | Previous (unsigned int dayNumber) const |
Previous monday, tuesday, etc. More... | |
LookDate | Next (unsigned int dayNumber) const |
Next monday, tuesday, etc. More... | |
bool | IsLeap (void) const |
Are we a leap year? | |
bool | Set (LookString theDateString) |
Set from a string. More... | |
LookString | GetString (const LookString &theSeparator="/", const LookString &theOrder="dmy", bool monthIsNumber=true, int yearDigits=4) const |
Get as a string. More... | |
Static Public Methods | |
LookDate | Now (void) |
Today according to localtime(). | |
unsigned int | DayFromName (LookString theDayName) |
Convert a weekday from a name to a number. More... | |
LookString | NameFromDay (unsigned int theDayNumber) |
Convert a weekday from a number to a name. More... | |
LookString | ShortNameFromDay (unsigned int theDayNumber) |
Convert a weekday from a number to a short name. More... | |
unsigned int | MonthFromName (LookString theMonthName) |
Convert a month from a name to a number. More... | |
LookString | NameFromMonth (unsigned int theMonthNumber) |
Convert a month number to a month name. More... | |
LookString | ShortNameFromMonth (unsigned int theMonthNumber) |
Convert a month number to a short month name. More... | |
unsigned int | DaysInMonth (unsigned int theMonthNumber, unsigned int theYear) |
How many days are in a month/year. More... | |
bool | IsLeap (unsigned int theYear) |
Is theYear a leap year? | |
void | ConvertFromJulian (unsigned long theJulianDate, unsigned int &year, unsigned int &month, unsigned int &day) |
Convert from a julian date to day/month/year. More... | |
unsigned long | ConvertToJulian (unsigned int year, unsigned int month, unsigned int day) |
Convert day/month/year to a julian date. More... | |
void | SetCenturyBoundary (int theBoundary) |
Set century boundary. See LookDate::itsCenturyBoundary. | |
int | GetCenturyBoundary (void) |
Get century boundary. See LookDate::itsCenturyBoundary. | |
Protected Attributes | |
unsigned long | itsJulianDate |
Julian date. | |
Static Protected Attributes | |
unsigned int | itsCenturyBoundary |
Century conversion boundary. More... |
This class represents a date.
It stores its value as a julian date, ie the number of days since one day a very long time ago. (a standard one though...)
This version doesn't handle anything but the gregorian calendar, so don't use it for dates < Sep. 14, 1752.
The conversions to and from strings are English-only at the moment.
|
Constructor. The default value of 0 will make IsSet() return false. |
|
Constructor. theDay is 1-31, theMonth 1-12, theYear the full 4-digit year. If any combination of these is invalid, itsJulianDate will be set to 0 and IsSet() will return false. |
|
Constructor. theDay is 1-31, theMonth either the full month name or the 3-letter abbreviation, theYear the full 4-digit year. theMonth is case-insensitive. If any combination of these is invalid, itsJulianDate will be set to 0 and IsSet() will return false. |
|
Convert from a julian date to day/month/year.
|
|
Convert day/month/year to a julian date. If day/month/year is not a valid date, then the return will be 0.
|
|
Convert a weekday from a name to a number. Monday = 1, Sunday = 7.
|
|
How many days are in a month/year. Obviously you need to give the year to account for leap years.
|
|
Get a new copy. Virtual copy constructor, aka clone.
Reimplemented from look::LookTypeBase. |
|
Get as a string. The D, M and Y characters of theOrder are considered (case-insensitive). The return string is build up with d's replaced by the day of the month, m's by the month string and y's by the year string. theSeparator is placed between all of these. Eg GetString( "/", "dmy", true, 4) will give "25/02/1993" and GetString( "-", "mdy", false, 2) will give "Feb-25-93" LookDateTimeFormatter is a much more general formatter, but not as efficient.
|
|
Get Type ID. Pseudo-rtti, or isA.
Reimplemented from look::LookTypeBase. |
|
Is the date set? Note adding 1 to an unset date results in a set date (although a very long time ago).
|
|
Convert a month from a name to a number. January = 1, December = 12.
|
|
Convert a weekday from a number to a name. Monday = 1, Sunday = 7.
|
|
Convert a month number to a month name. January = 1, December = 12.
|
|
Next monday, tuesday, etc. Like Previous(), only the next date.
|
|
Previous monday, tuesday, etc. Easiest described with an example - dayNumber = 3, Wednesday. If this date is a Tuesday, it returns the date 6 days before. If this date is a Wednesday, it retuns the date 7 days before. If this date is a Thursday, it retuns the date 1 day before. All of these are the previous Wednesday.
|
|
Set from a string. This can cope with a variety of formats. See LookDateTimeReader for a more general converter. The formats are:
If it is a two-digit year, it is converted to a four-digit year in 1900-2099 using itsCenturyBoundary. Only that portion of theDateString up to the first space is considered.
|
|
Convert a weekday from a number to a short name. Monday = 1, Sunday = 7.
|
|
Convert a month number to a short month name. January = 1, December = 12.
|
|
Add days.
|
|
Add days to self.
|
|
Days between two dates. The difference (in days) between self and theOther. If theOther is before self, the return will be negative.
|
|
Subtract days from self.
|
|
Subtract days from self.
|
|
Century conversion boundary. For converting two-digit years to four-digit - the Y2K problem. If boundary is 10, 11 is converted to 1911 and 10 to 2010 |