ucommon::Date Class Reference

The Date class uses a julian date representation of the current year, month, and day.julian number based date class. More...

#include <datetime.h>

Inheritance diagram for ucommon::Date:

Inheritance graph
[legend]

Public Member Functions

 Date ()
 Construct a new julian date with today's date.
 Date (Date &object)
 Create a julian date object from another object.
 Date (int year, unsigned month, unsigned day)
 Create a julian date from an arbitrary year, month, and day.
 Date (char *pointer, size_t size=0)
 Create a julian date from a ISO date string of a specified size.
 Date (struct tm *object)
 Create a julian date from a local or gmt date and time.
 Date (time_t value)
 Create a julian date from a time_t type.
unsigned day (void)
 Get the day of the month of the date.
unsigned dow (void)
 Get the day of the week (0-7).
long get (void)
 Get the date as a number for the object or 0 if invalid.
bool is_valid (void)
 Check if date is valid.
unsigned month (void)
 Get the month of the date (1-12).
long operator * ()
 Access julian value.
 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.
Date operator+ (long days)
 Add days to julian date in an expression.
Dateoperator++ ()
 Increment date by one day.
Dateoperator+= (long offset)
 Increment date by offset.
long operator- (Date &date)
 Operator to compute number of days between two dates.
Date operator- (long days)
 Subtract days from a julian date in an expression.
Dateoperator-- ()
 Decrement date by one day.
Dateoperator-= (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.
Dateoperator= (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.
char * put (char *buffer)
 Get a ISO string representation of the date (yyyy-mm-dd).
void set (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)
 Get a time_t for the julian date if in time_t epoch.
int year (void)
 Get the year of the date.
virtual ~Date ()
 Destroy julian date object.

Static Public Attributes

static 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

Detailed Description

The Date class uses a julian date representation of the current year, month, and day.julian number based date class.

This is then manipulated in several forms and may be exported as needed.

Author:
David Sugar <dyfet@ostel.com>

Definition at line 78 of file datetime.h.


Constructor & Destructor Documentation

ucommon::Date::Date ( time_t  value  ) 

Create a julian date from a time_t type.

Parameters:
value from time()

ucommon::Date::Date ( struct tm *  object  ) 

Create a julian date from a local or gmt date and time.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
object to copy.


Member Function Documentation

unsigned ucommon::Date::day ( void   ) 

Get the day of the month of the date.

Returns:
day of month

unsigned ucommon::Date::dow ( void   ) 

Get the day of the week (0-7).

Returns:
day of week

long ucommon::Date::get ( void   ) 

Get the date as a number for the object or 0 if invalid.

Returns:
date as number.

Reimplemented in ucommon::DateTime.

bool ucommon::Date::is_valid ( void   ) 

Check if date is valid.

Returns:
true if julian date is valid.

Reimplemented in ucommon::DateTime.

unsigned ucommon::Date::month ( void   ) 

Get the month of the date (1-12).

Returns:
month of year

long ucommon::Date::operator * (  )  [inline]

Access julian value.

Returns:
julian number of object.

Definition at line 212 of file datetime.h.

ucommon::Date::operator bool (  )  [inline]

Check if julian date is valid for is() expression.

Returns:
true if date is valid.

Reimplemented in ucommon::DateTime.

Definition at line 330 of file datetime.h.

ucommon::Date::operator long (  )  [inline]

Casting operator to return date as number.

Returns:
julian number.

Reimplemented in ucommon::DateTime.

Definition at line 205 of file datetime.h.

bool ucommon::Date::operator! (  )  [inline]

Check if julian date is not valid.

Returns:
true if date is invalid.

Reimplemented in ucommon::DateTime.

Definition at line 323 of file datetime.h.

bool ucommon::Date::operator!= ( Date date  ) 

Compare julian dates if not same date.

Parameters:
date to compare with.
Returns:
true if not same.

String ucommon::Date::operator() (  ) 

Expression operator to return an ISO date string for the current julian date.

Returns:
ISO date string.

Date ucommon::Date::operator+ ( long  days  ) 

Add days to julian date in an expression.

Parameters:
days to add.
Returns:
new date object with modified days.

Reimplemented in ucommon::DateTime.

Date& ucommon::Date::operator++ (  ) 

Increment date by one day.

Returns:
instance of current date object.

Reimplemented in ucommon::DateTime.

Date& ucommon::Date::operator+= ( long  offset  ) 

Increment date by offset.

Parameters:
offset to add to julian date.
Returns:
instance of current date object.

Reimplemented in ucommon::DateTime.

long ucommon::Date::operator- ( Date date  )  [inline]

Operator to compute number of days between two dates.

Parameters:
date offset for computation.
Returns:
number of days difference.

Definition at line 267 of file datetime.h.

References julian.

Date ucommon::Date::operator- ( long  days  ) 

Subtract days from a julian date in an expression.

Parameters:
days to subtract.
Returns:
new date object with modified days.

Reimplemented in ucommon::DateTime.

Date& ucommon::Date::operator-- (  ) 

Decrement date by one day.

Returns:
instance of current date object.

Reimplemented in ucommon::DateTime.

Date& ucommon::Date::operator-= ( long  offset  ) 

Decrement date by offset.

Parameters:
offset to subtract from julian date.
Returns:
instance of current date object.

Reimplemented in ucommon::DateTime.

bool ucommon::Date::operator< ( Date date  ) 

Compare julian date if earlier than another date.

Parameters:
date to compare with.
Returns:
true if earlier.

bool ucommon::Date::operator<= ( Date date  ) 

Compare julian date if earlier than or equal to another date.

Parameters:
date to compare with.
Returns:
true if earlier or same.

Date& ucommon::Date::operator= ( Date date  ) 

Assign date from another date object.

Parameters:
date object to assign from.
Returns:
current modified date object.

bool ucommon::Date::operator== ( Date date  ) 

Compare julian dates if same date.

Parameters:
date to compare with.
Returns:
true if same.

bool ucommon::Date::operator> ( Date date  ) 

Compare julian date if later than another date.

Parameters:
date to compare with.
Returns:
true if later.

bool ucommon::Date::operator>= ( Date date  ) 

Compare julian date if later than or equal to another date.

Parameters:
date to compare with.
Returns:
true if later or same.

char* ucommon::Date::put ( char *  buffer  ) 

Get a ISO string representation of the date (yyyy-mm-dd).

Parameters:
buffer to store string.
Returns:
string representation.

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.

Parameters:
pointer to date string field.
size of field if not null terminated.

time_t ucommon::Date::timeref ( void   ) 

Get a time_t for the julian date if in time_t epoch.

Returns:
time_t or -1 if out of range.

virtual void ucommon::Date::update ( void   )  [protected, virtual]

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::DateTime, ucommon::DateTimeString, and ucommon::DateNumber.

int ucommon::Date::year ( void   ) 

Get the year of the date.

Returns:
year of the date


The documentation for this class was generated from the following file:
Generated on 14 Aug 2013 for UCommon by  doxygen 1.4.7