UCommon
|
The Date class uses a julian date representation of the current year, month, and day. More...
#include <datetime.h>
Public Member Functions | |
Date () | |
Construct a new julian date with today's date. | |
Date (const char *pointer, size_t size=0) | |
Create a julian date from a ISO date string of a specified size. | |
Date (const Date &object) | |
Create a julian date object from another object. | |
Date (const struct tm *object) | |
Create a julian date from a local or gmt date and time. | |
Date (int year, unsigned month, unsigned day) | |
Create a julian date from an arbitrary year, month, and day. | |
Date (time_t value) | |
Create a julian date from a time_t type. | |
unsigned | day (void) const |
Get the day of the month of the date. | |
unsigned | dow (void) const |
Get the day of the week (0-7). | |
long | get (void) const |
Get the date as a number for the object or 0 if invalid. | |
bool | is_valid (void) const |
Check if date is valid. | |
unsigned | month (void) const |
Get the month of the date (1-12). | |
operator bool () const | |
Check if julian date is valid for is() expression. | |
operator long () const | |
Casting operator to return date as number. | |
bool | operator! () const |
Check if julian date is not valid. | |
bool | operator!= (const Date &date) const |
Compare julian dates if not same date. | |
stringref_t | operator() () const |
Expression operator to return an ISO date string for the current julian date. | |
long | operator* () const |
Access julian value. | |
const Date | operator+ (long days) const |
Add days to julian date in an expression. | |
Date & | operator++ () |
Increment date by one day. | |
Date & | operator+= (long offset) |
Increment date by offset. | |
long | operator- (const Date &date) |
Operator to compute number of days between two dates. | |
const Date | operator- (long days) const |
Subtract days from a julian date in an expression. | |
Date & | operator-- () |
Decrement date by one day. | |
Date & | operator-= (long offset) |
Decrement date by offset. | |
bool | operator< (const Date &date) const |
Compare julian date if earlier than another date. | |
bool | operator<= (const Date &date) const |
Compare julian date if earlier than or equal to another date. | |
Date & | operator= (const Date &date) |
Assign date from another date object. | |
bool | operator== (const Date &date) const |
Compare julian dates if same date. | |
bool | operator> (const Date &date) const |
Compare julian date if later than another date. | |
bool | operator>= (const Date &date) const |
Compare julian date if later than or equal to another date. | |
const char * | put (char *buffer) const |
Get a ISO string representation of the date (yyyy-mm-dd). | |
void | set (const char *pointer, size_t size=0) |
Set the julian date based on an ISO date string of specified size. | |
void | set (void) |
Set (update) the date with current date. | |
time_t | timeref (void) const |
Get a time_t for the julian date if in time_t epoch. | |
int | year (void) const |
Get the year of the date. | |
virtual | ~Date () |
Destroy julian date object. | |
Static Public Attributes | |
static const size_t | sz_string |
Size of date string field. | |
Protected Member Functions | |
void | set (long year, long month, long day) |
virtual void | update (void) |
A method to use to "post" any changed values when shadowing a mixed object class. | |
Protected Attributes | |
long | julian |
The Date class uses a julian date representation of the current year, month, and day.
This is then manipulated in several forms and may be exported as needed.
julian number based date class.
Definition at line 79 of file datetime.h.
ucommon::Date::Date | ( | time_t | value | ) |
Create a julian date from a time_t type.
value | from time() |
ucommon::Date::Date | ( | const struct tm * | object | ) |
Create a julian date from a local or gmt date and time.
object | from DateTime::glt() or gmt(). |
ucommon::Date::Date | ( | const char * | pointer, |
size_t | size = 0 ) |
Create a julian date from a ISO date string of a specified size.
pointer | to ISO date string. |
size | of date field if not null terminated. |
ucommon::Date::Date | ( | int | year, |
unsigned | month, | ||
unsigned | day ) |
Create a julian date from an arbitrary year, month, and day.
year | of date. |
month | of date (1-12). |
day | of month (1-31). |
ucommon::Date::Date | ( | const Date & | object | ) |
Create a julian date object from another object.
object | to copy. |
unsigned ucommon::Date::day | ( | void | ) | const |
unsigned ucommon::Date::dow | ( | void | ) | const |
long ucommon::Date::get | ( | void | ) | const |
Get the date as a number for the object or 0 if invalid.
bool ucommon::Date::is_valid | ( | void | ) | const |
Check if date is valid.
unsigned ucommon::Date::month | ( | void | ) | const |
|
inline |
Check if julian date is valid for is() expression.
Definition at line 335 of file datetime.h.
|
inline |
Casting operator to return date as number.
Definition at line 206 of file datetime.h.
|
inline |
Check if julian date is not valid.
Definition at line 327 of file datetime.h.
bool ucommon::Date::operator!= | ( | const Date & | date | ) | const |
Compare julian dates if not same date.
date | to compare with. |
stringref_t ucommon::Date::operator() | ( | ) | const |
Expression operator to return an ISO date string for the current julian date.
|
inline |
const Date ucommon::Date::operator+ | ( | long | days | ) | const |
Add days to julian date in an expression.
days | to add. |
Date & ucommon::Date::operator++ | ( | ) |
Increment date by one day.
Date & ucommon::Date::operator+= | ( | long | offset | ) |
Increment date by offset.
offset | to add to julian date. |
|
inline |
Operator to compute number of days between two dates.
date | offset for computation. |
Definition at line 270 of file datetime.h.
const Date ucommon::Date::operator- | ( | long | days | ) | const |
Subtract days from a julian date in an expression.
days | to subtract. |
Date & ucommon::Date::operator-- | ( | ) |
Decrement date by one day.
Date & ucommon::Date::operator-= | ( | long | offset | ) |
Decrement date by offset.
offset | to subtract from julian date. |
bool ucommon::Date::operator< | ( | const Date & | date | ) | const |
Compare julian date if earlier than another date.
date | to compare with. |
bool ucommon::Date::operator<= | ( | const Date & | date | ) | const |
Compare julian date if earlier than or equal to another date.
date | to compare with. |
Assign date from another date object.
date | object to assign from. |
bool ucommon::Date::operator== | ( | const Date & | date | ) | const |
Compare julian dates if same date.
date | to compare with. |
bool ucommon::Date::operator> | ( | const Date & | date | ) | const |
Compare julian date if later than another date.
date | to compare with. |
bool ucommon::Date::operator>= | ( | const Date & | date | ) | const |
Compare julian date if later than or equal to another date.
date | to compare with. |
const char * ucommon::Date::put | ( | char * | buffer | ) | const |
Get a ISO string representation of the date (yyyy-mm-dd).
buffer | to store string. |
void ucommon::Date::set | ( | const char * | pointer, |
size_t | size = 0 ) |
Set the julian date based on an ISO date string of specified size.
pointer | to date string field. |
size | of field if not null terminated. |
time_t ucommon::Date::timeref | ( | void | ) | const |
Get a time_t for the julian date if in time_t epoch.
|
protectedvirtual |
A method to use to "post" any changed values when shadowing a mixed object class.
This is used by DateNumber and string classes.
Reimplemented in ucommon::DateNumber, ucommon::DateTime, and ucommon::DateTimeString.
int ucommon::Date::year | ( | void | ) | const |
|
protected |
Definition at line 82 of file datetime.h.
|
static |
Size of date string field.
Definition at line 96 of file datetime.h.