Date Class Reference

#include <date.h>

List of all members.

Public Member Functions

 Date ()
 Date (int mm, int dd, int yy)
void setDate (int mm, int dd, int yy)
void input (istream &in)
void output (ostream &out) const
bool before (const Date &date) const
bool equal (const Date &date) const
bool after (const Date &date) const

Private Attributes

int mm
int dd
int yy

Friends

ostream & operator<< (ostream &out, const Date &date)
istream & operator>> (istream &in, Date &date)


Detailed Description

A class for storing dates. Dates are in the format MM/DD/YYYY.

Author:
Mark Maloof (maloof@cs)
Version:
1.0, 7/13/10

Constructor & Destructor Documentation

Date::Date (  ) 

Default constructor. Sets a defalt object to "01/01/2000".

Date::Date ( int  mm,
int  dd,
int  yy 
)

Explicit constructor. Sets the date to the specified values.

Parameters:
mm the month, an int value in [1, 12]
dd the day, an int value in [1, 28, 30, 31], depending on the month
yy the year, an int value greater than or equal to 0


Member Function Documentation

void Date::setDate ( int  mm,
int  dd,
int  yy 
)

Sets this Date object. Fails silently by not setting values that are out of range.

Parameters:
mm the month, an int value in [1, 12]
dd the day, an int value in [1, 28, 30, 31], depending on the month
yy the year, an int value greater than or equal to 0

void Date::input ( istream &  in  ) 

Inputs or reads a Date object in the format "MM/DD/YYYY" from the input stream. Sets the fail bit of the input stream if the object is improperly formatted.

Parameters:
in the input stream for reading

void Date::output ( ostream &  out  )  const

Ouputs this Date object in the format "MM/DD/YYYY" to the specified output stream with an end-of-line character.

Parameters:
out the output stream

bool Date::before ( const Date date  )  const

Returns true if this date is before the specified date; returns false otherwise.

Parameters:
date the specified date
Returns:
a bool indicating whether this date is before the parameter

bool Date::equal ( const Date date  )  const

Returns true if this date is equal to the specified date; returns false otherwise.

Parameters:
date the specified date
Returns:
a bool indicating whether this date is equal to the parameter

bool Date::after ( const Date date  )  const

Returns true if this date is after the specified date; returns false otherwise.

Parameters:
date the specified date
Returns:
a bool indicating whether this date is after the parameter


Friends And Related Function Documentation

ostream& operator<< ( ostream &  out,
const Date date 
) [friend]

Inserts a Date object in the format "MM/DD/YYYY" into the output stream, and returns the modified output stream.

Parameters:
out the output stream for insertion
date the Date object for insertion
Returns:
the modified output stream

istream& operator>> ( istream &  in,
Date date 
) [friend]

Extracts a Date object in the format "MM/DD/YYYY" from the input stream, and returns the modified input stream.

Parameters:
in the input stream for extraction
date the Date object for storing the extracted information
Returns:
the modified input stream


Member Data Documentation

int Date::mm [private]

the month of the year

int Date::dd [private]

the day of the month

int Date::yy [private]

the year


The documentation for this class was generated from the following files:

Generated on Wed Jul 21 13:30:09 2010 by  doxygen 1.5.5