ucommon
|
The Date class uses a julian date representation of the current year, month, and day. More...
#include <datetime.h>
Public Types | |
enum | index_t { year = 10, month, day, dow } |
index elements. |
Public Member Functions | |
Date (time_t value) | |
Create a julian date from a time_t type. | |
Date (struct tm *object) | |
Create a julian date from a local or gmt date and time. | |
Date (char *pointer, size_t size=0) | |
Create a julian date from a ISO date string of a specified size. | |
Date (int year, unsigned month=1, unsigned day=1) | |
Create a julian date from an arbitrary year, month, and day. | |
Date (Date &object) | |
Create a julian date object from another object. | |
Date () | |
Construct a new julian date with today's date. | |
char * | get (char *buffer) |
Get a ISO string representation of the date (yyyy-mm-dd). | |
long | get (void) |
Get the date as a number for the object or 0 if invalid. | |
unsigned | getDay (void) |
Get the day of the month of the date. | |
unsigned | getDayOfWeek (void) |
Get the day of the week (0-7). | |
long | getJulian (void) |
Get the julian number of a date. | |
unsigned | getMonth (void) |
Get the month of the date (1-12). | |
time_t | getTime (void) |
Get a time_t for the julian date if in time_t epoch. | |
int | getYear (void) |
Get the year of the date. | |
bool | isValid (void) |
Check if date is valid. | |
operator bool () | |
Check if julian date is valid for is() expression. | |
operator long () | |
Casting operator to return date as number. | |
bool | operator! () |
Check if julian date is not valid. | |
bool | operator!= (Date &date) |
Compare julian dates if not same date. | |
String | operator() () |
Expression operator to return an ISO date string for the current julian date. | |
long | operator* () |
Access julian value. | |
Date | operator+ (long days) |
Add days to julian date in an expression. | |
Date & | operator++ () |
Increment date by one day. | |
Date & | operator+= (long offset) |
Increment date by offset. | |
Date | operator- (long days) |
Subtract days from a julian date in an expression. | |
long | operator- (Date &date) |
Operator to compute number of days between two dates. | |
Date & | operator-- () |
Decrement date by one day. | |
Date & | operator-= (long offset) |
Decrement date by offset. | |
bool | operator< (Date &date) |
Compare julian date if earlier than another date. | |
bool | operator<= (Date &date) |
Compare julian date if earlier than or equal to another date. | |
Date & | operator= (Date &date) |
Assign date from another date object. | |
bool | operator== (Date &date) |
Compare julian dates if same date. | |
bool | operator> (Date &date) |
Compare julian date if later than another date. | |
bool | operator>= (Date &date) |
Compare julian date if later than or equal to another date. | |
int | operator[] (index_t component) |
Access numeric components. | |
void | set (void) |
Set (update) the date with current date. | |
void | set (char *pointer, size_t size=0) |
Set the julian date based on an ISO date string of specified size. | |
virtual | ~Date () |
Destroy julian date object. |
Static Public Attributes | |
static size_t | sz_string |
Size of date string field. |
Protected Member Functions | |
void | fromJulian (char *buf) |
void | toJulian (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.
Definition at line 73 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 | ( | struct tm * | object | ) |
Create a julian date from a local or gmt date and time.
object | from DateTime::glt() or gmt(). |
ucommon::Date::Date | ( | 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 = 1 , |
||
unsigned | day = 1 |
||
) |
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 | ( | Date & | object | ) |
Create a julian date object from another object.
object | to copy. |
char* ucommon::Date::get | ( | char * | buffer | ) |
Get a ISO string representation of the date (yyyy-mm-dd).
buffer | to store string. |
Reimplemented in ucommon::DateTime.
long ucommon::Date::get | ( | void | ) |
Get the date as a number for the object or 0 if invalid.
Reimplemented in ucommon::DateTime.
unsigned ucommon::Date::getDay | ( | void | ) |
Get the day of the month of the date.
unsigned ucommon::Date::getDayOfWeek | ( | void | ) |
Get the day of the week (0-7).
|
inline |
unsigned ucommon::Date::getMonth | ( | void | ) |
Get the month of the date (1-12).
time_t ucommon::Date::getTime | ( | void | ) |
Get a time_t for the julian date if in time_t epoch.
int ucommon::Date::getYear | ( | void | ) |
Get the year of the date.
bool ucommon::Date::isValid | ( | void | ) |
|
inline |
Check if julian date is valid for is() expression.
Reimplemented in ucommon::DateTime.
Definition at line 345 of file datetime.h.
|
inline |
Casting operator to return date as number.
Reimplemented in ucommon::DateTime.
Definition at line 213 of file datetime.h.
|
inline |
Check if julian date is not valid.
Reimplemented in ucommon::DateTime.
Definition at line 338 of file datetime.h.
bool ucommon::Date::operator!= | ( | Date & | date | ) |
Compare julian dates if not same date.
date | to compare with. |
String ucommon::Date::operator() | ( | ) |
Expression operator to return an ISO date string for the current julian date.
|
inline |
Date ucommon::Date::operator+ | ( | long | days | ) |
Add days to julian date in an expression.
days | to add. |
Reimplemented in ucommon::DateTime.
Date& ucommon::Date::operator++ | ( | ) |
Increment date by one day.
Reimplemented in ucommon::DateTime.
Date& ucommon::Date::operator+= | ( | long | offset | ) |
Increment date by offset.
offset | to add to julian date. |
Reimplemented in ucommon::DateTime.
Date ucommon::Date::operator- | ( | long | days | ) |
Subtract days from a julian date in an expression.
days | to subtract. |
Reimplemented in ucommon::DateTime.
|
inline |
Operator to compute number of days between two dates.
date | offset for computation. |
Definition at line 282 of file datetime.h.
Date& ucommon::Date::operator-- | ( | ) |
Decrement date by one day.
Reimplemented in ucommon::DateTime.
Date& ucommon::Date::operator-= | ( | long | offset | ) |
Decrement date by offset.
offset | to subtract from julian date. |
Reimplemented in ucommon::DateTime.
bool ucommon::Date::operator< | ( | Date & | date | ) |
Compare julian date if earlier than another date.
date | to compare with. |
bool ucommon::Date::operator<= | ( | Date & | date | ) |
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== | ( | Date & | date | ) |
Compare julian dates if same date.
date | to compare with. |
bool ucommon::Date::operator> | ( | Date & | date | ) |
Compare julian date if later than another date.
date | to compare with. |
bool ucommon::Date::operator>= | ( | Date & | date | ) |
Compare julian date if later than or equal to another date.
date | to compare with. |
int ucommon::Date::operator[] | ( | index_t | component | ) |
Access numeric components.
component | to access. |
Reimplemented in ucommon::DateTime.
void ucommon::Date::set | ( | 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. |
|
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::DateTimeString, and ucommon::DateTime.