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 operator< (const Date &date) const
bool operator> (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, 1/19/11

Constructor & Destructor Documentation

Date::Date (  ) 

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

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::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
bool Date::operator< ( const Date date  )  const

Returns true if this date is before (i.e., less than) the specified date; returns false otherwise.

Parameters:
date the specified date
Returns:
a bool indicating whether this date is before the specified date
bool Date::operator> ( const Date date  )  const

Returns true if this date is after (i.e., greater than) the specified date; returns false otherwise.

Parameters:
date the specified date
Returns:
a bool indicating whether this date is after the specified date
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
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

Friends And Related Function Documentation

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

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 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::dd [private]

the day of the month

int Date::mm [private]

the month of the year

int Date::yy [private]

the year


The documentation for this class was generated from the following files:
Generated on Thu Jan 20 18:07:03 2011 by  doxygen 1.6.3