Webmaster  |  Imprint 
Platinum
Platinum C++ Framework
Main  |  License  |  Documentation  |  Download  |  Support 

Date Class Reference
[DateTime]

Date expressed in year, month, and day

#include <Pt/Date.h>

List of all members.

Public Types

enum  Month {
  Jan = 1,
  Feb,
  Mar,
  Apr,
  May,
  Jun,
  Jul,
  Aug,
  Sep,
  Oct,
  Nov,
  Dec
}
enum  WeekDay {
  Sun = 0,
  Mon,
  Tue,
  Wed,
  Thu,
  Fri,
  Sat
}

Public Member Functions

 Date ()
 Default constructor.
 Date (const Date &date)
 Copy constructor.
 Date (int y, unsigned m, unsigned d)
 Constructs a Date from given values.
 Date (unsigned julianDays)
 Constructs a Date from a julian day.
void setJulian (unsigned d)
 Sets the Date to a julian day.
unsigned julian () const
 Returns the Date as a julian day.
void set (int year, unsigned month, unsigned day)
 Sets the date to a year, month and day.
void get (int &year, unsigned &month, unsigned &day) const
 Gets the year, month and day.
unsigned day () const
 Returns the day-part of the date.
unsigned month () const
 Returns the month-part of the date.
int year () const
 Returns the year-part of the date.
unsigned dayOfWeek () const
 Return day of the week, starting with sunday.
unsigned daysInMonth () const
 Returns the days of the month of the date.
unsigned dayOfYear () const
 Returns the day of the year.
bool leapYear () const
 Returns true if the date is in a leap year.
Dateoperator= (const Date &date)
 Assignment operator.
Dateoperator+= (int days)
 Add days to the date.
Dateoperator-= (int days)
 Substract days from the date.
Dateoperator++ ()
 Increments the date by one day.
Dateoperator-- ()
 Decrements the date by one day.
bool operator== (const Date &date) const
 Returns true if the dates are equal.
bool operator!= (const Date &date) const
 Returns true if the dates are not equal.
bool operator< (const Date &date) const
 Less-than comparison operator.
bool operator<= (const Date &date) const
 Less-than-equal comparison operator.
bool operator> (const Date &date) const
 Greater-than comparison operator.
bool operator>= (const Date &date) const
 Greater-than-equal comparison operator.
std::string toIsoString () const
 Returns the date in ISO-format.

Static Public Member Functions

static Date fromIsoString (const std::string &s)
 Interprets a string as a date-string in ISO-format.
static bool isValid (int y, int m, int d)
 Returns true if values describe a valid date.
static bool leapYear (int year)
 Returns true if the year is in a leap year.
static void greg2jul (unsigned &jd, int y, int m, int d)
 Converts a gergorian date to a julian day.
static void jul2greg (unsigned jd, int &y, int &m, int &d)
 Converts a julian day to a gregorian date.

Static Public Attributes

static const unsigned DaysPerYear = 365
 The number of days of an ordinary year.
static const unsigned DaysPerLeapYear = 366
 The number of days of a leap year.
static const unsigned DaysOfJan = 31
 The number of days of a January.
static const unsigned DaysOfFeb = 28
 The number of days of a February.
static const unsigned DaysOfLeapFeb = 29
 The number of days of a February in a leap year.
static const unsigned DaysOfMar = 31
 The number of days of a March.
static const unsigned DaysOfApr = 30
 The number of days of a April.
static const unsigned DaysOfMay = 31
 The number of days of a May.
static const unsigned DaysOfJun = 30
 The number of days of a June.
static const unsigned DaysOfJul = 31
 The number of days of a July.
static const unsigned DaysOfAug = 31
 The number of days of a August.
static const unsigned DaysOfSep = 30
 The number of days of a September.
static const unsigned DaysOfOct = 31
 The number of days of a October.
static const unsigned DaysOfNov = 30
 The number of days of a November.
static const unsigned DaysOfDec = 31
 The number of days of a December.

Friends

Date operator+ (const Date &d, int days)
Date operator+ (int days, const Date &d)
int operator- (const Date &a, const Date &b)


Constructor & Destructor Documentation

Date (  ) 

The default constructed date is undefined.

Date ( int  y,
unsigned  m,
unsigned  d 
)

Sets the date to a new year, month and day. InvalidDate is thrown if any of the values is out of range


Member Function Documentation

void set ( int  year,
unsigned  month,
unsigned  day 
)

Sets the date to a new year, month and day. InvalidDate is thrown if any of the values is out of range

std::string toIsoString (  )  const

Converts the date in ISO-format (yyyy-mm-dd).

Returns:
Date as iso formated string.

static Date fromIsoString ( const std::string &  s  )  [static]

Interprets a string as a date-string in ISO-format (yyyy-mm-dd) and returns a Date-object. When the string is not in ISO-format, an exception is thrown.

Parameters:
s Iso formated date string.
Returns:
Date result
Exceptions:
IllegalArgument 

Copyright © 2003-2007 The Pt Development Team
Pt 1.0