Skip to content

Date class

Colin Girling edited this page Feb 19, 2017 · 9 revisions

Types

typedef uint32_t size_type;
typedef int32_t diff_type;
typedef uint8_t day_type;
typedef uint8_t day_of_week_type;
typedef uint8_t month_type;
typedef uint16_t year_type;

Constants

static day_type const MIN_DAY = 1U;
static day_type const MAX_DAY = 31U;
static day_type const DAYS_IN_LEAP_FEBRUARY = 29U;

static size_type const DAYS_PER_YEAR = 365U;
static size_type const DAYS_PER_LEAP_YEAR = 366U;

static day_type const DAYS_IN_JANUARY = 31U;
static day_type const DAYS_IN_FEBRUARY = 28U;
static day_type const DAYS_IN_MARCH = 31U;
static day_type const DAYS_IN_APRIL = 30U;
static day_type const DAYS_IN_MAY = 31U;
static day_type const DAYS_IN_JUNE = 30U;
static day_type const DAYS_IN_JULY = 31U;
static day_type const DAYS_IN_AUGUST = 31U;
static day_type const DAYS_IN_SEPTEMBER = 30U;
static day_type const DAYS_IN_OCTOBER = 31U;
static day_type const DAYS_IN_NOVEMBER = 30U;
static day_type const DAYS_IN_DECEMBER = 31U;

static size_type const MONTHS_PER_YEAR = 12U;

static year_type const DEFAULT_YEAR = 1970U;

static day_of_week_type const SUNDAY = 0U;
static day_of_week_type const MONDAY = 1U;
static day_of_week_type const TUESDAY = 2U;
static day_of_week_type const WEDNESDAY = 3U;
static day_of_week_type const THURSDAY = 4U;
static day_of_week_type const FRIDAY = 5U;
static day_of_week_type const SATURDAY = 6U;

static month_type const JANUARY = 1U;
static month_type const FEBRUARY = 2U;
static month_type const MARCH = 3U;
static month_type const APRIL = 4U;
static month_type const MAY = 5U;
static month_type const JUNE = 6U;
static month_type const JULY = 7U;
static month_type const AUGUST = 8U;
static month_type const SEPTEMBER = 9U;
static month_type const OCTOBER = 10U;
static month_type const NOVEMBER = 11U;
static month_type const DECEMBER = 12U;

static month_type const MIN_MONTH = JANUARY;
static month_type const MAX_MONTH = DECEMBER;

Constructors

Date() throw(); // Default to 1st January 1970

Date(day_type day,
     month_type month,
     year_type year) throw();

Date(Date const& date) throw();

Operators

Date& operator =(Date const& date) throw();
bool operator <(Date const& other) const throw();
bool operator <=(Date const& other) const throw();
bool operator >(Date const& other) const throw();
bool operator >=(Date const& other) const throw();
bool operator ==(Date const& other) const throw();
bool operator !=(Date const& other) const throw();
Date& operator +=(size_type days_to_add) throw(); // Add milliseconds.
Date& operator -=(size_type days_to_subtract) throw(); // Subtract milliseconds.
Date operator +(size_type days) throw(); // Add milliseconds.
Date operator -(size_type days) const throw(); // Subtract milliseconds.
diff_type operator -(Date const& other) const throw(); // Get difference between two dates.
Date operator++() throw(); // Prefix add milliseconds.
Date operator++(int) throw(); // Postfix add milliseconds.
Date operator--() throw(); // Prefix subtract milliseconds.
Date operator--(int) throw(); // Postfix subtract milliseconds.

Static member functions

Member functions

Clone this wiki locally