.TH "FBB::DateTime" "3bobcat" "2005\-2018" "libbobcat\-dev_4\&.08\&.06\-x\&.tar\&.gz" "Date and Time" .PP .SH "NAME" FBB::DateTime \- Performs Date and Time Computations .PP .SH "SYNOPSIS" \fB#include \fP .br Linking option: \fI\-lbobcat\fP .PP .SH "DESCRIPTION" .PP This class allows the programmer to manipulate date and time values\&. Individual time fields can be requested or modified, returning `sanitized\(cq\& times (e\&.g\&., a date like march 33 or a time like 56 hours will never be returned)\&. Times may be specified in local time or in \fIUniversal Time Coordinated\fP (\fIUTC\fP) values\&. It is also possible to add or subtract seconds or \fBstruct tm\fP structures to or from \fIDateTime\fP objects\&. This operation keeps the current time zone (\fIUTC\fP, local or another time zone)\&. Conversions between time zones and \fIUTC\fP are also supported\&. .PP The class \fIDateTime\fP supports various ways to initialize objects\&. Time may be specified in UTC, as local time or using any other offset from UTC\&. When an explicit time offset is requested it is specified as an \fIint\fP value representing the time offset in minutes, with time zones time zones West of Greenwich using negative time offsets and East of Greenwich using positive time offsets\&. Time zone offsets are truncated to multiples of 30 minutes and are always computed modulo 12 * 60, as no time zone has a shift exceeding the (absolute) shift of 12 * 60\&. Daylight saving times are in effect in many time zones\&. Except for the local time zone \fIDateTime\fP may not be able to show the correct daylight saving time correction\&. .PP There are various ways to construct \fIDateTime\fP objects: time in seconds since the beginning of the `era\(cq\& (midnight Jan 1, 1970 UTC), a \fIstruct tm\fP, or a textual time representations may be used\&. These values may themselves be corrected using display zone shifts\&. A display zone shift determines the difference between the UTC time and the local time zone to be used when displaying time or returning time fields\&. Sometimes a UTC zone shift may be provided correcting a provided local time to UTC\&. .PP If a display zone shift is explicitly specified no additional daylight saving time (DST) zone shift is added to the display time\&. If the actual local time is requested (specified by the \fITimeType\fP value \fILOCALTIME\fP) a DST correction is automatically applied when appropriate\&. .PP Members of the class \fIDateTime\fP should only be used if \fIoperator bool()\fP returns \fItrue\fP\&. The member \fIerror()\fP can also be used if \fIoperator bool()\fP returns false\&. .PP Handling time is complex\&. The \fBC\fP function \fBtime\fP(2) returns the time in seconds\&. This time is normally represented in UTC\&. The function \fBgmtime\fP(3) when provided with \fItime()\fP\(cq\&s output returns the broken down time in a \fIstruct tm\fP\&. Remarkably (and confusingly), when this \fIstruct tm\fP is then passed to the \fBmktime\fP(3) function the latter function does \fInot\fP return the UTC\-time in seconds, but a time that differs from the time in UTC by the current local time shift\&. E\&.g\&., the program .nf #include #include using namespace std; int main() { time_t utc = time(0); struct tm *ts; time_t local = mktime(ts = gmtime(&utc)); cout << ts\->tm_hour << \(cq\& \(cq\& << utc \- local << endl; } .fi displays the current \fIUTC\fP clock\(cq\&s hour setting, but reports the difference in seconds between the local time and the UTC time (e\&.g\&., the difference between CET and UTC is one hour, and the program displays 3600)\&. .PP To obtain the time in UTC\-seconds from \fImktime\fP(3) the function \fBlocaltime\fP(3) must be used to obtain the \fIstruct tm\fP values: .nf #include #include using namespace std; int main() { time_t utc = time(0); struct tm *ts; time_t local = mktime(ts = localtime(&utc)); cout << ts\->tm_hour << \(cq\& \(cq\& << utc \- local << endl; } .fi The above program displays the local clock\(cq\&s hour value, but a difference of 0 for the recomputed time in seconds\&. .PP The class \fIDateTime\fP assumes that the \fItime()\fP function returns the UTC time in seconds, which is the way computers should have configured their hardware clock\&. .PP .SH "NAMESPACE" \fBFBB\fP .br All constructors, members, operators and manipulators, mentioned in this man\-page, are defined in the namespace \fBFBB\fP\&. .PP .SH "INHERITS FROM" \- .PP .SH "ENUMS defined in DateTime" .PP \fBDateTime::Month\fP .br This enumeration has the following values which are ordered using the default \fBC++\fP \fIenum\fP values: .IP o \fBJANUARY\fP, .IP o \fBFEBRUARY\fP, .IP o \fBMARCH\fP, .IP o \fBAPRIL\fP, .IP o \fBMAY\fP, .IP o \fBJUNE\fP, .IP o \fBJULY\fP, .IP o \fBAUGUST\fP, .IP o \fBSEPTEMBER\fP, .IP o \fBOCTOBER\fP, .IP o \fBNOVEMBER\fP, .IP o \fBDECEMBER\fP\&. .PP \fBDateTime::Relative\fP .br This enumeration is used with the \fIsetMonth()\fP member (see below)\&. It has the following values: .IP o \fBTHIS_WEEK\fP, .IP o \fBTHIS_YEAR\fP, .IP o \fBLAST\fP, .IP o \fBNEXT\fP .PP \fBDateTime::TimeFields\fP .br This enumeration has the following values which can be \fIbit_or\fP\-ed when calling the member \fIsetFields()\fP: .IP o \fBSECONDS\fP .IP o \fBMINUTES\fP .IP o \fBHOURS\fP .IP o \fBMONTHDAY\fP .IP o \fBMONTH\fP .IP o \fBYEAR\fP .PP \fBDateTime::TimeType\fP .br This enumeration has the following values: .IP o \fBLOCALTIME\fP: the time is broken down as the local time, .IP o \fBUTC\fP: the time is broken down as Universal Time Coordinated\&. .PP \fBDateTime::TriVal\fP .br This enumeration has the following values, returned by the \fBdst()\fP member (see below): .IP o \fBUNKNOWN\fP, returned when no information about the Daylight Saving Time is available, .IP o \fBNO\fP, returned when Daylight Saving Time is not active, .IP o \fBYES\fP, returned when Daylight Saving Time is active\&. .PP \fBDateTime::Weekday\fP .br This enumeration has the following values which are ordered using the default \fBC++\fP \fIenum\fP values: .PP .IP o \fBSUNDAY\fP, .IP o \fBMONDAY\fP, .IP o \fBTUESDAY\fP, .IP o \fBWEDNESDAY\fP, .IP o \fBTHURSDAY\fP, .IP o \fBFRIDAY\fP, .IP o \fBSATURDAY\fP\&. .PP .SH "STANDARD TEXTUAL TIME REPRESENTATIONS" .PP \fIDateTime\fP objects may be initialized using textual time\-representations\&. Also, the time represented by a \fIDateTime\fP object may be altered using text which can be extracted from a stream using the extraction operator\&. .PP Time specifications may be formatted as follows: .IP o \fISun Nov 2 13:29:11 2008\fP, as displayed by the \fBC\fP function \fIasctime()\fP; .IP .IP o \fISun Nov 2 13:29:11 CET 2008\fP, as displayed by the \fBdate\fP(1) program; .IP .IP o \fISun, Nov 2 13:29:11 2008 +0100\fP, as displayed by the \fIdate \-R\fP command (and the \fIrfc2822()\fP member, see below); .IP .IP o \fI2008\-11\-02 13:29:11+01:00\fP, as displayed by the \fIdate \-\-rfc\-3339=seconds\fP command (and the \fIrfc3339()\fP member, see below)\&. .PP The time zone time shift specifications (+0100, +01:00) are required as they are part of the rfc specifications but are ignored for the actual local time construction as the \fIDateTime\fP object determines the time zone specification from the computer\(cq\&s current time zone setting\&. .PP .SH "CONSTRUCTORS" .PP .IP o \fBDateTime(TimeType type = UTC)\fP: .br The default constructor, initializing the object to the current date and time\&. The argument specifies the way the time is displayed by the \fIDateTime\fP object using either (by default) time in UTC or the computer\(cq\&s time zone shift is used to determine the current local time\&. .IP .IP o \fBDateTime(int tzShift)\fP: .br This constructor initializes the object to a local time which is at UTC + tzShift (in minutes)\&. .IP .IP o \fBDateTime(time_t time, TimeType type)\fP: .br Initializes a \fIDateTime\fP object with information stored in the provided \fItime_t\fP value (time in seconds since the beginning of the era)\&. The specified \fItime\fP is considered UTC or local time, depending on the \fItype\fP specification\&. .IP .IP o \fBDateTime(time_t time, int tzShift)\fP: .br Initializes a \fIDateTime\fP object with information stored in the provided \fItime_t\fP value (time is UTC time in seconds since the beginning of the era)\&. The \fIDateTime\fP object defines its time as local time UTC + tzShift (in minutes)\&. .PP The following constructors ignore the DST, day of the year, and day of the week fields of the \fIstruct tm\fP passed to the constructors: .PP .IP o \fBDateTime(struct tm const &tm, TimeType type = UTC)\fP: .br Initializes a \fIDateTime\fP object with information stored in the provided \fBstruct tm\fP value\&. It is assumed that the \fItm\fP parameter points to a \fIstruct tm\fP representing the broken down time in either UTC or local time\&. If local time is requested the the computer\(cq\&s time zone shift is used\&. The \fBstruct tm\fP is defined as follows: .nf struct tm { int tm_sec; // seconds 0\&.\&.59, or 60: leap second int tm_min; // minutes 0\&.\&.59 int tm_hour; // hours 0\&.\&.23 int tm_mday; // day of the month 1\&.\&.31 int tm_mon; // month 0\&.\&.11 int tm_year; // year since 1900 int tm_wday; // day of the week 0\&.\&.6 int tm_yday; // day in the year 0\&.\&.365 int tm_isdst; // daylight saving time // > 0: yes, 0: no, < 0: unknown }; .fi Values outside of these ranges may sometimes be used (with various set\&.\&.() members, see below) to compute a point in time in the future or in the past\&. E\&.g\&., by specifying 30 for the hour\-setting \fBDateTime\fP objects a point in time in the next day will be used\&. .IP .IP o \fBDateTime(struct tm const &tm, int timeShift)\fP: .br Initializes a \fIDateTime\fP object with information stored in the provided \fBstruct tm\fP value\&. It is assumed that the \fItm\fP parameter points to a \fIstruct tm\fP representing the broken down time fields in UTC\&. To this time shift \fItzShift\fP (in minutes) is added to obtain the actually used local time\&. .PP The final constructors convert textual time specifications formatted as described in section \fBSTANDARD TEXTUAL TIME REPRESENTATIONS\fP (the day of the week specification is ignored by the time conversion)\&. .PP .IP o \fBDateTime(std::string const &timeStr, TimeType type = UTC)\fP: .br Initializes a \fIDateTime\fP object with information stored in the provided \fIstd::string\fP which is interpreted as time specified in UTC or as a local time in the current time zone, depending on the specified time type\&. .IP .IP o \fBDateTime(std::string const &timeStr, int tzShift)\fP: .br Initializes a \fIDateTime\fP object with a local time computed by adding a locate timezone shift (\fItzShift\fP) in minutes to the UTC time specification found in \fItimeStr\fP\&. .PP The copy constructor is available\&. .PP .SH "OVERLOADED OPERATORS" .PP All class\-less overloaded operators are defined in the \fIFBB\fP namespace, except for the overloaded insertion operator, which is defined in the \fIstd\fP namespace\&. .PP .IP o \fBstd::ostream &std::operator<<(std::ostream &str, FBB::DateTime const &dt)\fP: .br Inserts a standard textual representation (without the trailing newline), of the time represented in the \fIDateTime\fP object into the indicated \fIostream\fP\&. The time will be displayed according to the latest \fIdisplayZoneShift\fP or \fITimeType\fP specification (\fILOCALTIME\fP or \fIUTC\fP)\&. .IP .IP o \fBstd::istream &std::operator>>(std::istream &str, FBB::DateTime &dt)\fP: .br Extracts a textual date/time representation into the \fIDateTime\fP object using the \fItzShift\fP value currently set for the \fIDateTime\fP object into which the time string is extracted\&. .IP The \fIistream\fP from which the time is extracted must contain time formatted as described in section \fBSTANDARD TEXTUAL TIME REPRESENTATIONS\fP\&. As documented in that section, time shift and time zone specifications (+0100, +01:00, CET) are ignored and may be omitted\&. They are ignored when specified\&. The object will merely interpret the date/time specification as a specification in the object\(cq\&s currently active time zone\&. .IP If the time could not be determined from a textual string representing the time (cf\&. section \fBCONSTRUCTORS\fP) then \fIerrno()\fP returns 0, \fIoperator bool()\fP returns \fIfalse\fP, and the time stored in the object remains unchanged\&. .PP The following overloaded operators modify the time as stored in UTC seconds within objects\&. Note that the time as displayed by the object will be corrected for any display zone shift that may have been defined for those objects\&. .PP .IP o \fBDateTime const operator+(DateTime const &left, time_t seconds)\fP: .br Returns a copy of \fIleft\fP to which \fIseconds\fP have been added\&. .IP .IP o \fBDateTime const operator+(DateTime const &left, struct tm const &fields)\fP: .br Returns a copy of \fIleft\fP displaying \fIleft\fP\(cq\&s time to which the \fItm_sec, tm_min, tm_hour, tm_mday, tm_mon\fP and \fItm_year\fP fields of \fIfields\fP have been added\&. .IP .IP o \fBDateTime operator+=(time_t seconds)\fP: .br Adds the number of seconds to the \fIDateTime\fP object\&. .IP .IP o \fBDateTime &operator+=(struct tm const &fields)\fP: .br Adds the \fItm_sec, tm_min, tm_hour, tm_mday, tm_mon\fP and \fItm_year\fP fields of \fIfields\fPto the current object\(cq\&s display time\&. .IP .IP o \fBDateTime const operator\-(DateTime const &left, time_t seconds)\fP: .br Returns a copy of \fIleft\fP from which time \fIseconds\fP have been subtracted\&. .IP .IP o \fBDateTime const operator\-(DateTime const &left, struct tm const &fields)\fP: .br Returns a copy of \fIleft\fP displaying \fIleft\fP\(cq\&s time from which the \fItm_sec, tm_min, tm_hour, tm_mday, tm_mon\fP and \fItm_year\fP fields of \fIfields\fP have been subtracted\&. .IP .IP o \fBDateTime operator\-=(time_t seconds)\fP: .br Subtracts the number of seconds from the time stored in the \fIDateTime\fP object\&. .IP .IP o \fBDateTime &operator\-=(struct tm const &fields)\fP: .br Subtracts the \fItm_sec, tm_min, tm_hour, tm_mday, tm_mon\fP and \fItm_year\fP fields of \fIfields\fP from the current object\(cq\&s display time\&. E\&.g\&., the following code fragment will display midnight, January 1, 1970: .nf time_t seconds = time(0); tm timeStruct = *gmtime(&seconds); DateTime tmp(timeStruct); cout << tmp << endl; \-\-timeStruct\&.tm_mday; // days start at 1: subtract 1 less than // the current day number to get \(cq\&01\(cq\& timeStruct\&.tm_year \-= (1970 \- 1900); // era starts at 1970, tm_year // is relative to 1900\&. tmp \-= timeStruct; cout << tmp << endl; .fi .PP The following overloaded operators can be used to compare the UTC time as represented by \fIDateTime\fP objects\&. Note that these comparisons are independent of any display zone shift that may have been defined for the objects\&. .PP .IP o \fBbool operator==(DateTime const &left, DateTime const &right)\fP: .br Returns \fItrue\fP if the current \fIDateTime\fP object represents the same UTC time as the time represented by \fIleft, DateTime const &right\fP\&. .IP .IP o \fBbool operator!=(DateTime const &left, DateTime const &right)\fP: .br Returns \fItrue\fP if the current \fIDateTime\fP object represents a different UTC time as the time represented by \fIother\fP\&. .IP .IP o \fBbool operator<(DateTime const &left, DateTime const &right)\fP: .br Returns \fItrue\fP if the current \fIDateTime\fP object represents an earlier UTC time than the UTC time represented by \fIother\fP\&. .IP .IP o \fBbool operator<=(DateTime const &left, DateTime const &right)\fP: .br Returns \fItrue\fP if the current \fIDateTime\fP object represents an earlier or equal UTC time than the UTC time represented by \fIother\fP\&. .IP .IP o \fBbool operator>(DateTime const &left, DateTime const &right)\fP: .br Returns \fItrue\fP if the current \fIDateTime\fP object represents a later UTC time than the UTC time represented by \fIother\fP\&. .IP .IP o \fBbool operator>=(DateTime const &left, DateTime const &right)\fP: .br Returns \fItrue\fP if the current \fIDateTime\fP object represents an equal or later UTC time than the UTC time represented by \fIother\fP\&. .PP Additional overloaded operators: .PP .IP o \fBoperator bool() const\fP: .br Returns \fBtrue\fP if the time decomposition could be performed without error\&. \fIDateTime\fP object use \fBlocaltime_r\fP(3) or \fBgmtime_r\fP(3) functions to break down the \fItime_t\fP values into elements\&. If the time could not be broken down, the \fBerror()\fP member returns the error number (\fIerrno\fP) associated with the error\&. When the time could not be determined from a textual string representing the time (cf\&. section \fBCONSTRUCTORS\fP) then \fIerrno()\fP returns 0 and \fIoperator bool()\fP returns \fIfalse\fP\&. .br Except for the member \fIerror()\fP the members of the class \fIDateTime\fP will not return meaningful values if \fBoperator bool()\fP returns \fIfalse\fP\&. .IP .IP o \fBDateTime &operator=(DateTime const &other)\fP: .br The overloaded asignment operator is available\&. .PP .SH "MEMBER FUNCTIONS" .PP All members returning a time\-element do so according to the latest time\-representation (i\&.e\&., \fIUTC\fP, \fILOCALTIME\fP, or using an explicitly set display zone shift value)\&. All members returning numerical values use 0 as their smallest return value, except for the \fB\&.\&.\&.Nr()\fP members, which start at 1\&. .IP o \fBint displayZoneShift() const\fP: .br Returns the object\(cq\&s current display zone shift value in minutes\&. .IP .IP o \fBDayTime::TriVal dst() const\fP: .br Returns an indication of an active Daylight Saving Time (DST) state for the (local) time represented in the \fIDateTime\fP object\&. When DST is active, the local time is one hour later as compared to the situation where DST is not active\&. .IP .IP o \fBsize_t error() const\fP: .br Returns the \fIerrno\fP value after the \fIDateTime\fP object\&. construction\&. It can be interpreted by, e\&.g\&., \fBFBB::Exception\fP\&. .IP .IP o \fBsize_t hours() const\fP: .br Returns the number of hours of the time stored in a \fIDateTime\fP object (0\-23)\&. .IP .IP o \fBDateTime localTime() const\fP: .br Returns a copy of the \fIDateTime\fP object representing its local time\&. If the object does not define a local time or display zone shift the returned object merely copies the original object\(cq\&s UTC time\&. .IP .IP o \fBDateTime localTime(int displayZoneShift) const\fP: .br Returns a copy of the \fIDateTime\fP object representing its time using the display zone shift provided by the member\(cq\&s argument\&. .IP .IP o \fBsize_t minutes() const\fP: .br Returns the number of minutes of the time stored in a \fIDateTime\fP object (0\-59)\&. .IP .IP o \fBMonth month() const\fP: .br Returns the \fIMonth\fP value of the time stored in a \fIDateTime\fP object\&. .IP .IP o \fBsize_t monthDayNr() const\fP: .br Returns the number of the day in the month of the time stored in a \fIDateTime\fP object (1\-31)\&. .IP .IP o \fBstring rfc2822() const\fP: .br Returns the date displayed according to the format specified in RFC 2822\&. This format is used, e\&.g\&., by the \fIdate \-R\fP command (cf\&. \fBdate\fP(1))\&. For example: .nf Mon, 17 Dec 2007 13:49:10 +0100 .fi .IP .IP o \fBstring rfc3339() const\fP: .br Returns the date displayed according to the format specified in RFC 3339\&. This format is used, e\&.g\&., by the \fIdate \-\-rfc\-3339=seconds\fP command (cf\&. \fBdate\fP(1))\&. For example: .nf 2008\-11\-02 13:29:11+01:00 .fi .IP .IP o \fBsize_t seconds() const\fP: .br Returns the number of seconds of the time stored in a \fIDateTime\fP object (0\-59, but 60 and 61 may occur due to possible leap seconds)\&. .IP .IP o \fBbool setDay(int days)\fP: .br Reassigns the number of days of the current month set in the \fIDateTime\fP object\&. Non positive values are allowed to compute time in an earlier month\&. The object date is revalidated so that its \fIdays()\fP member returns a value fitting the object\(cq\&s month\&. If the assignment resulted in a new (valid) time \fItrue\fP is returned\&. Otherwise \fIfalse\fP is returned\&. .IP .IP o \fBbool setFields(struct tm const &timeStruct, int fields)\fP: .br Reassigns the time represented by the \fIDateTime\fP object to the time in which the fields specified by a \fIbit_or\fP combination of \fITimeField\fP values will be given the values specified in \fItimeStruct\fP\&. All other fields in \fItimeStruct\fP will be ignored and will be kept at their internal values\&. The values will be normalized, though\&. E\&.g\&., if the current month day number is 31 and month June is requested then the resulting month will be \fIJuly\fP and the day number will be 1\&. The \fItimeStruct\fP fields are expected as values in the time zone used by the \fIDateTime\fP object\&. If the assignment resulted in a new (valid) time \fItrue\fP is returned\&. Otherwise \fIfalse\fP is returned\&. .IP .IP o \fBbool setHours(int hours)\fP: .br Reassigns the number of hours set in the \fIDateTime\fP object\&. Negative values are allowed to compute time in a previous day\&. The object date is revalidated so that its \fIhours()\fP member returns a value between 0 and 23\&. If the assignment resulted in a new (valid) time \fItrue\fP is returned\&. Otherwise \fIfalse\fP is returned\&. .IP .IP o \fBbool setMinutes(int minutes)\fP: .br Reassigns the number of minutes set in the \fIDateTime\fP object\&. Negative values are allowed to compute time in a previous hour\&. The object date is revalidated so that its \fIminutes()\fP member returns a value between 0 and 59\&. If the assignment resulted in a new (valid) time \fItrue\fP is returned\&. Otherwise \fIfalse\fP is returned\&. .IP .IP o \fBbool setMonth(DateTime::Month month, DateTime::Relative where = THIS_YEAR)\fP: .br Reassigns the month set in the \fIDateTime\fP object\&. The object date is revalidated so that its \fImonth()\fP member returns a value between \fIJANUARY\fP and \fIDECEMBER\fP\&. By default the month will be set in the current year\&. \fIDateTime::LAST\fP may be specified to ensure that the requested month will be before the current month (e\&.g\&., the current month: \fIJUNE\fP, requesting \fIAUGUST, LAST\fP will decrement the object\(cq\&s year, but \fIMAY, LAST\fP won\(cq\&t)\&. Analogously, \fIDateTime::NEXT\fP may be specified to ensure that the requested month will be following the current month\&. If another value for \fIwhere\fP is specified an \fBException\fP exception is thrown\&. If the assignment resulted in a new (valid) time \fItrue\fP is returned\&. Otherwise \fIfalse\fP is returned\&. .IP Caveat: When setting the month the month may inadvertently be set to the next month\&. This happens when the current day number exceeds the number of days in the target month\&. Example: assume it is December 31st and the intent is to change the date to June 21st\&. The first example sets the date to \fBJuly\fP 21st since `June 31st\(cq\& is converted to `July 1st\(cq\&\&. The second example sets the date to June 21st, as intended\&. .nf DateTime dt; // assume set at December 31 dt\&.setMonth(DateTime::JUNE); // becomes JULY dt\&.setDay(21); // Now July 21st DateTime dt; // assume set at December 31 dt\&.setDay(21); // Now December 21st dt\&.setMonth(DateTime::JUNE); // OK: June 21st .fi .IP .IP o \fBbool setMonth(int month)\fP: .br Reassigns the month set in the \fIDateTime\fP object\&. Negative values are allowed to compute time in a previous year\&. The object date is revalidated so that its \fImonth()\fP member returns a value between \fIJANUARY\fP and \fIDECEMBER\fP\&. If the assignment resulted in a new (valid) time \fItrue\fP is returned\&. Otherwise \fIfalse\fP is returned\&. .IP .IP o \fBbool setSeconds(int seconds)\fP: .br Reassigns the number of seconds set in the \fIDateTime\fP object\&. Negative values are allowed to compute time in a previous minute\&. The object date is revalidated so that its \fIseconds()\fP member returns a value between 0 and 59\&. If the assignment resulted in a new (valid) time \fItrue\fP is returned\&. Otherwise \fIfalse\fP is returned\&. .IP .IP o \fBbool setTime(time_t time)\fP: .br Reassigns the number of seconds set in the \fIDateTime\fP object\&. The object date is revalidated\&. Time value 0 represents Jan, 1, 1970, 0:00:00 hours\&. If the assignment resulted in a new (valid) time \fItrue\fP is returned\&. Otherwise \fIfalse\fP is returned\&. .IP .IP o \fBvoid setValid()\fP: .br Resets the object\(cq\&s internal state to valid\&. This member can be used following a failed action that did not modify the (valid) time stored by the object\&. .IP .IP o \fBbool setWeekday(Weekday day, Relative where = NEXT)\fP: .br Reassigns the number of seconds set in the \fIDateTime\fP object based on reassignment of the day in the week (at most 7 days from now, weeks starting at Sunday and ending at Saturday)\&. By default the day will be in the future\&. By specifying \fILAST\fP for \fIwhere\fP the day will be in the past\&. It is also possible to specify \fIwhere\fP as \fITHIS_WEEK\fP in which case the day will be computed in the current week\&. If another value for \fIwhere\fP is specified an \fBException\fP exception is thrown\&. If the current weekday is specified with \fIwhere\fP equal to either \fINEXT\fP or \fILAST\fP the time will be set to either one week ahead or one week in the past\&. The object date is revalidated\&. Time value 0 represents Jan, 1, 1970, 0:00:00 hours\&. If the assignment resulted in a new (valid) time \fItrue\fP is returned\&. Otherwise \fIfalse\fP is returned\&. .IP .IP o \fBbool setYear(size_t year)\fP: .br Reassigns the year set in the \fIDateTime\fP object\&. The date is revalidated so that its \fIyear()\fP member returns a value of at least 1970\&. If the assignment resulted in a new (valid) time \fItrue\fP is returned\&. Otherwise \fIfalse\fP is returned\&. .IP .IP o \fBtime_t time() const\fP: .br Returns the (UTC) \fItime_t\fP value (in seconds) stored in the \fIDateTime\fP object\&. .IP .IP o \fBstruct tm const *timeStruct() const\fP: .br Returns a pointer to the objects latest \fIstruct tm\fP values, representing the time as displayed by, e\&.g\&., the insertion operator\&. .IP .IP o \fBDateTime to(DateTime::TimeType type) const\fP: .br Returns a copy of the \fIDateTime\fP object representing its time in \fIUTC\fP if \fIDateTime::UTC\fP was specified, and in local time if \fIDateTime::LOCALTIME\fP was specified\&. .IP .IP o \fBDateTime utc() const\fP: .br Returns a copy of the \fIDateTime\fP object representing its time in \fIUTC\fP\&. .IP .IP o \fBbool valid() const\fP: .br Returns \fItrue\fP if no errors were detected during the object\(cq\&s construction (same semantics as \fIoperator bool()\fP)\&. .IP .IP o \fBWeekday weekday() const\fP: .br Returns the \fIWeekday\fP value of the time stored in a \fIDateTime\fP object\&. .IP .IP o \fBsize_t year() const\fP: .br Returns the year element of the time stored in a \fIDateTime\fP object\&. .IP .IP o \fBsize_t yearDay() const\fP: .br Returns the day within the year of the time stored in a \fIDateTime\fP object\&. January 1 is returned as 0\&. .IP .IP o \fBsize_t yearDayNr() const\fP: .br Returns the day within the year of the time stored in a \fIDateTime\fP object\&. January 1 is returned as 1\&. .IP Whenever a \fIset\&.\&.\&.()\fP member is used in such a way that the resulting date would be invalid the original \fIDateTime\fP object\(cq\&s value is unaltered\&. .PP .SH "EXAMPLE" .PP An extensive example illustrating the use of all of \fIDateTime\fP\(cq\&s members is provided in the file \fIbobcat/datetime/driver/driver\&.cc\fP found in the source archive\&. .PP .SH "FILES" \fIbobcat/datetime\fP defines the class interface\&. .PP .SH "SEE ALSO" \fBbobcat\fP(7), \fBException\fP(3bobcat), \fBasctime_r\fP(3), \fBgmtime_r\fP(3), \fBlocaltime_r\fP(3), \fBtime\fP(2), \fBmktime\fP(3), .PP .SH "BUGS" The class \fIDateTime\fP assumes that \fBtime\fP(2) returns the time in UTC\&. .br English is used / expected when specifying named date components\&. .PP .SH "DISTRIBUTION FILES" .IP o \fIbobcat_4\&.08\&.06\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_4\&.08\&.06\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_4\&.08\&.06\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_4\&.08\&.06\-x_*\&.deb\fP: debian package holding the libraries; .IP o \fIlibbobcat1\-dev_4\&.08\&.06\-x_*\&.deb\fP: debian package holding the libraries, headers and manual pages; .IP o \fIhttp://sourceforge\&.net/projects/bobcat\fP: public archive location; .PP .SH "BOBCAT" Bobcat is an acronym of `Brokken\(cq\&s Own Base Classes And Templates\(cq\&\&. .PP .SH "COPYRIGHT" This is free software, distributed under the terms of the GNU General Public License (GPL)\&. .PP .SH "AUTHOR" Frank B\&. Brokken (\fBf\&.b\&.brokken@rug\&.nl\fP)\&. .PP