Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields  

sword::Date Class Reference

Date (dmy h:m:s) storage and conversions. More...

Inheritance diagram for sword::Date:

sword::Comparable< Date >

Public Methods

 Date () throw ()
 Default constructor, creates an empty date.

 Date (const Date &rhs) throw ()
 Copy constructor.

Date & operator= (const Date &rhs) throw ()
 copy operator

 Date (word day, word month, word year, word hour, word minute, word second, word millis, const Calendar &calendar) throw ()
 Builds a date from 'dmy h:m:s' components.

 Date (word day, word month, word year, word hour, word minute, word second, word millis) throw ()
 Builds a date from 'dmy h:m:s' components.

 Date (word day, word month, word year, const Calendar &calendar) throw ()
 Builds a date from 'dmy' components.

 Date (word day, word month, word year) throw ()
 Builds a date from 'dmy' components.

 Date (Time time, const Calendar &calendar)
 Builds a date from a Time timestamp.

 Date (Time time)
 Builds a date from a Time timestamp.

 Date (int packed, const Calendar &calendar)
 Builds a date from its packed int representation (ddmmyyyy).

 Date (int packed)
 Builds a date from its packed int representation (ddmmyyyy).

word day () const throw ()
 day of the month read accessor (1..31)

word month () const throw ()
 month read accessor (1..12)

word year () const throw ()
 year read accessor (absolute value, eg. 2003)

word hour () const throw ()
 hour read accessor (0..23)

word minute () const throw ()
 minute read accessor (0..59)

word second () const throw ()
 second read accessor (0..59)

word millis () const throw ()
 milliseconds read accessor (0..999)

const Calendarcalendar () const throw ()
 calendar used for time-date conversions

word weekDay () const
 day of the week read accessor (0=Sunday..6=Saturday)

word weekNumber () const
 week number (1..52)

word dayWithinYear () const
 day within the year (1..366)

void day (word value) throw ()
 day of the month write accessor (1..31)

void month (word value) throw ()
 month write accessor (1..12)

void year (word value) throw ()
 year write accessor (absolute value, eg. 2003)

void hour (word value) throw ()
 hour write accessor (0..23)

void minute (word value) throw ()
 minute write accessor (0..59)

void second (word value) throw ()
 second write accessor (0..59)

void millis (word value) throw ()
 milliseconds write accessor (0..999)

bool empty () const throw ()
 Is this date the empty date ?

void clear () throw ()
 Clear this date to the empty date.

void set (word day, word month, word year, word hour, word minute, word second, word millis, const Calendar &calendar) throw ()
 Set the date to these dmy h:m:s components.

void set (word day, word month, word year, const Calendar &calendar) throw ()
 Set the date to these dmy components (the hour is assumed to be 0:0:0).

void addYears (int years, bool endToEnd=false)
 Adds the given number of years to the date.

void addMonths (int months, bool endToEnd=false)
 Adds the given number of months to the date.

void addDays (int days)
 Adds the given number of days to the date.

void addHours (int hours)
 Adds the given number of hours to the date.

void addMinutes (int minutes)
 Adds the given number of minutes to the date.

void addSeconds (int seconds)
 Adds the given number of seconds to the date.

void addMillis (int millis)
 Adds the given number of milliseconds to the date.

void next ()
 Compute the next day.

void prev ()
 Compute the previous day.

void fromTime (Time time, const Calendar &calendar)
 Explodes a Time timestamp into a Date.

void fromTime (Time time)
 Explodes a Time timestamp into a Date.

Time toTime () const
 Implodes a Date into a Time timestamp.

void fromPackedDate (int packed, const Calendar &calendar)
 Explodes an int into a Date, ex: 20030430 = 30th april 20003.

void fromPackedDate (int packed)
 Explodes an int into a Date, ex: 20030430 = 30th april 20003.

int toPackedDate () const
 Imploses a Date into an int date ex: 20030430 = 30th april 20003.

bool valid () const
 Checks whether this date is a valid date.

std::string toString (const std::string &format) const
 Prints a date onto a string using a custom format.

void fromString (const std::string &format, const std::string &data)
 Extracts a date from a formatted string.

bool operator< (const Comparable< Date > &rhs) const
 '<' operation between this instance and rhs

bool operator<= (const Comparable< Date > &rhs) const
 '<=' operation between this instance and rhs

bool operator> (const Comparable< Date > &rhs) const
 '>' operation between this instance and rhs

bool operator>= (const Comparable< Date > &rhs) const
 '>=' operation between this instance and rhs

bool operator== (const Comparable< Date > &rhs) const
 '==' operation between this instance and rhs

bool operator!= (const Comparable< Date > &rhs) const
 '!=' operation between this instance and rhs


Static Public Methods

Date now (const Calendar &calendar)
 Get the current date, in local time.

Date now ()
 Get the current date, in local time.

Date nowUTC (const Calendar &calendar)
 Get the current date, in UTC.

Date nowUTC ()
 Get the current date, in UTC.

int compare (const Date &lhs, const Date &rhs)
 Comparison method (used for Ordered<> implementation).


Static Public Attributes

const char * formatRFC822UTC
const char * formatRFC822

Detailed Description

Date (dmy h:m:s) storage and conversions.


Constructor & Destructor Documentation

sword::Date::Date   throw ()
 

Default constructor, creates an empty date.

sword::Date::Date const Date &    rhs throw ()
 

Copy constructor.

sword::Date::Date word    day,
word    month,
word    year,
word    hour,
word    minute,
word    second,
word    millis,
const Calendar   calendar
throw ()
 

Builds a date from 'dmy h:m:s' components.

sword::Date::Date word    day,
word    month,
word    year,
word    hour,
word    minute,
word    second,
word    millis
throw ()
 

Builds a date from 'dmy h:m:s' components.

The calendar is assumed to be the Gregorian calendar

sword::Date::Date word    day,
word    month,
word    year,
const Calendar   calendar
throw ()
 

Builds a date from 'dmy' components.

The hour is assume to be 0:0:0.

sword::Date::Date word    day,
word    month,
word    year
throw ()
 

Builds a date from 'dmy' components.

The hour is assumed to be 0:0:0, and the calendar is assumed to be the Gregorian calendar

sword::Date::Date Time    time,
const Calendar   calendar
 

Builds a date from a Time timestamp.

sword::Date::Date Time    time
 

Builds a date from a Time timestamp.

The calendar is assumed to be the Gregorian calendar

sword::Date::Date int    packed,
const Calendar   calendar
 

Builds a date from its packed int representation (ddmmyyyy).

sword::Date::Date int    packed
 

Builds a date from its packed int representation (ddmmyyyy).

The calendar is assumed to be the Gregorian calendar


Member Function Documentation

void sword::Date::addDays int    days
 

Adds the given number of days to the date.

void sword::Date::addHours int    hours
 

Adds the given number of hours to the date.

void sword::Date::addMillis int    millis
 

Adds the given number of milliseconds to the date.

void sword::Date::addMinutes int    minutes
 

Adds the given number of minutes to the date.

void sword::Date::addMonths int    months,
bool    endToEnd = false
 

Adds the given number of months to the date.

The number of months can be negative to go back in time. It can be also 0 which is equivalent to a no-operation. The 'endToEnd' flag specifies whether the end of the months should be preserved.

void sword::Date::addSeconds int    seconds
 

Adds the given number of seconds to the date.

void sword::Date::addYears int    years,
bool    endToEnd = false
 

Adds the given number of years to the date.

The number of years can be negative to go back in time. It can be also 0 which is equivalent to a no-operation. The 'endToEnd' flag specifies whether the end of the month should be preserved. For instance, with endToEnd = false, 28feb1995 plus 1 year equals 28feb1996. On the contrary, with endToEnd = true, the result would be 29feb1996.

const Calendar& sword::Date::calendar   const throw ()
 

calendar used for time-date conversions

void sword::Date::clear   throw ()
 

Clear this date to the empty date.

int sword::Date::compare const Date &    lhs,
const Date &    rhs
[static]
 

Comparison method (used for Ordered<> implementation).

void sword::Date::day word    value throw ()
 

day of the month write accessor (1..31)

word sword::Date::day   const throw ()
 

day of the month read accessor (1..31)

word sword::Date::dayWithinYear   const
 

day within the year (1..366)

bool sword::Date::empty   const throw ()
 

Is this date the empty date ?

void sword::Date::fromPackedDate int    packed
 

Explodes an int into a Date, ex: 20030430 = 30th april 20003.

void sword::Date::fromPackedDate int    packed,
const Calendar   calendar
 

Explodes an int into a Date, ex: 20030430 = 30th april 20003.

void sword::Date::fromString const std::string &    format,
const std::string &    data
 

Extracts a date from a formatted string.

The format string must conform the format syntax as described in Date::toString. The data is parsed and every formatter is matched against the formatted text.

void sword::Date::fromTime Time    time
 

Explodes a Time timestamp into a Date.

The Gregorian calendar is used by default.

void sword::Date::fromTime Time    time,
const Calendar   calendar
 

Explodes a Time timestamp into a Date.

void sword::Date::hour word    value throw ()
 

hour write accessor (0..23)

word sword::Date::hour   const throw ()
 

hour read accessor (0..23)

void sword::Date::millis word    value throw ()
 

milliseconds write accessor (0..999)

word sword::Date::millis   const throw ()
 

milliseconds read accessor (0..999)

void sword::Date::minute word    value throw ()
 

minute write accessor (0..59)

word sword::Date::minute   const throw ()
 

minute read accessor (0..59)

void sword::Date::month word    value throw ()
 

month write accessor (1..12)

word sword::Date::month   const throw ()
 

month read accessor (1..12)

void sword::Date::next  
 

Compute the next day.

Date sword::Date::now   [static]
 

Get the current date, in local time.

The calendar is assumed to be the Gregorian calendar.

See also:
Date::nowUTC

Date sword::Date::now const Calendar   calendar [static]
 

Get the current date, in local time.

See also:
Date::nowUTC

Date sword::Date::nowUTC   [static]
 

Get the current date, in UTC.

The calendar is assumed to be the Gregorian calendar.

See also:
Date::now

Date sword::Date::nowUTC const Calendar   calendar [static]
 

Get the current date, in UTC.

See also:
Date::now

bool sword::Comparable< Date >::operator!= const Comparable< Date > &    rhs const [inherited]
 

'!=' operation between this instance and rhs

bool sword::Comparable< Date >::operator< const Comparable< Date > &    rhs const [inherited]
 

'<' operation between this instance and rhs

bool sword::Comparable< Date >::operator<= const Comparable< Date > &    rhs const [inherited]
 

'<=' operation between this instance and rhs

Date& sword::Date::operator= const Date &    rhs throw ()
 

copy operator

bool sword::Comparable< Date >::operator== const Comparable< Date > &    rhs const [inherited]
 

'==' operation between this instance and rhs

bool sword::Comparable< Date >::operator> const Comparable< Date > &    rhs const [inherited]
 

'>' operation between this instance and rhs

bool sword::Comparable< Date >::operator>= const Comparable< Date > &    rhs const [inherited]
 

'>=' operation between this instance and rhs

void sword::Date::prev  
 

Compute the previous day.

void sword::Date::second word    value throw ()
 

second write accessor (0..59)

word sword::Date::second   const throw ()
 

second read accessor (0..59)

void sword::Date::set word    day,
word    month,
word    year,
const Calendar   calendar
throw ()
 

Set the date to these dmy components (the hour is assumed to be 0:0:0).

void sword::Date::set word    day,
word    month,
word    year,
word    hour,
word    minute,
word    second,
word    millis,
const Calendar   calendar
throw ()
 

Set the date to these dmy h:m:s components.

int sword::Date::toPackedDate   const
 

Imploses a Date into an int date ex: 20030430 = 30th april 20003.

std::string sword::Date::toString const std::string &    format const
 

Prints a date onto a string using a custom format.

The format string may contain the following codes (inspired from PHP date() function) together with normal characters that will be directly copied into the output string:

  • %a : 'am' or 'pm'
  • %A : 'AM' or 'PM'
  • %d : Day of the month, 2 digits (01..31)
  • %D : Day of the week, textual, 3 letters (eg. Fri)
  • %F : Month, textual, long (eg. January)
  • %g : Hour, 12-hour cycle, no leading 0 (1..12)
  • %G : Hour, 24-hour cycle, no leading 0 (1..24)
  • %h : Hour, 12-hour cycle, 2 digits (01..12)
  • %H : Hour, 24-hour cycle, 2 digits (01..24)
  • %i : Minutes, 2 digits (00..59)
  • %j : Day of the month, no leading 0 (1..31)
  • %l : Day of the week, textual, long (eg. Friday)
  • %L : Milliseconds (000...999)
  • %m : Month, 2 digits (01..12)
  • %M : Month, textual, 3 letters (eg. Jan)
  • %n : Month, no leading 0 (1..12)
  • %O : Different to greenwitch, in hours (eg. +0200)
  • %s : Seconds, 2 digits (00..59)
  • %S : English day suffix (st, nd, rd or th)
  • %w : Day of week, numeric (0=Sunday to 6=Saturday)
  • %W : Week number, numeric (1..52)
  • %Y : Year, 4 digits (eg. 1984, 2003)
  • %y : Year, 2 digits (eg. 84, 03)
  • %%: Print the '%' character

Time sword::Date::toTime   const
 

Implodes a Date into a Time timestamp.

bool sword::Date::valid   const
 

Checks whether this date is a valid date.

word sword::Date::weekDay   const
 

day of the week read accessor (0=Sunday..6=Saturday)

This method will require that the attached calendar implements the WesternCalendar interface, otherwise it will throw an 'bad_cast' exception.

word sword::Date::weekNumber   const
 

week number (1..52)

void sword::Date::year word    value throw ()
 

year write accessor (absolute value, eg. 2003)

word sword::Date::year   const throw ()
 

year read accessor (absolute value, eg. 2003)


Generated on Tue Dec 23 20:08:56 2003 for SWORD by doxygen1.3-rc2