Class Date.

Inherits Garbage

The Date class contains a date, with attendant time and timezeone.

It can parse RFC 822 format dates, as well as encode dates in rfc822, imap and ISO-8601 formats. It cannot change itself or interact with other dates: This is meant purely as parse-and-store class.

Date::Date()

Constructs an empty, invalid Date.

Reimplements Garbage::Garbage().

void Date::checkHarder()

Checks that a presumably valid date really is. Flags November 31 as invalid, all dates before 1900 ditto, etc, etc.

uint Date::day() const

Returns the date's day-of-month (1-31), or 0 if the date isn't valid().

uint Date::hour() const

Returns this Date's hour (0-23), or 0 if the Date isn't valid.

EString Date::imap() const

Returns an IMAP-format date-time, or an empty string if the date is invalid.

(date-day-fixed "-" date-month "-" date-year SP time SP zone)

EString Date::isoDate() const

Returns the date part of the object as a ten-character ISO8601 date, eg. "2004-02-29".

EString Date::isoDateTime() const

Returns the RFC 3339 (ISO 8601) format date (with date, time, offset all mangled together: YYYY-MM-DDTHH:MM:SS+NN:NN).

EString Date::isoTime() const

Returns the time part of the object as an eight-character ISO8601 string, e.g. "01:22:59".

Returns an empty string if the date is invalid.

uint Date::minute() const

Returns this Date's minute (0-59), or 0 if the Date isn't valid.

uint Date::month() const

Returns the date's month (1 for January, 12 for December), or 0 if the date isn't valid().

int Date::offset() const

Returns the timezone offset, or 0 if the date is invalid. Note that +0000 and -0000 are indistinguishable in the Date API.

EString Date::rfc822() const

Returns the date in RFC 822 format. If it's too far into the past or future, the weekday is omitted (as is legal).

Returns an empty string if the date is invalid.

uint Date::second() const

Returns this Date's second (0-60), or 0 if the Date isn't valid.

void Date::setCurrentTime()

Sets this date to point to the current date, time and timezone.

void Date::setDate( uint year, const EString & month, uint day, uint hour, uint minute, uint second, int zone )

A version of setDate() that takes a month name instead of a number, for use with IMAP (as opposed to ISO) date-time. The year, day, hour, minute, second, and zone arguments are handled identically.

void Date::setDate( uint year, uint month, uint day, uint hour, uint minute, uint second, int zone )

Sets the date to the supplied (in this order) year, month, day, hour, minute, second, zone, all of which are presumed to be sensible. If they aren't sensible, the object becomes invalid.

void Date::setIsoDateTime( const EString & dt )

Parses dt as an RFC 3339 (ISO 8601) format date and sets it.

void Date::setLocalTimezone()

Transforms this Date from whatever time zone it is currently in to the local time zone, whatever that is.

void Date::setRfc822( const EString & s )

Sets this date object to reflect the RFC 2822-format date s. If there are any syntax errors, the date is set to be invalid.

A number of common syntax errors are accepted.

void Date::setTimezone( const EString & z )

Transforms this Date to be in the time zone z, which must be in "[+-]HHMM" format. If z is in any way invalid, the Date will not be valid() afterwards. If z is "-0000", this function does nothing (as a concession to Sieve's :originalzone).

void Date::setUnixTime( uint t )

Sets this date to t seconds after the start of 1970, give or take a few leap seconds. t is assumed to be UTC.

uint Date::unixTime()

Returns the unix time corresponding to this data, or 0 if the data is invalid.

bool Date::valid() const

Returns true if the object is a legal date, and false if the date is meaningless, unparsable or uninitialized.

uint Date::weekday() const

Returns this Date's day-of-week (0..6, with 0 being Sunday), or 0 if the Date isn't valid.

uint Date::year() const

Returns the date's year, or 0 in case the date isn't valid().

This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.