#include <OW_DateTime.hpp>
Public Types | |
enum | ETimeOffset { E_LOCAL_TIME, E_UTC_TIME } |
The values of this enum are passed to various functions to as a flag to indicate the timezone context desired. More... | |
Public Member Functions | |
DateTime () | |
Create a new DateTime object that represents the Epoch (00:00:00 UTC, January 1, 1970). | |
DateTime (const String &str) | |
Create a new DateTime object from a string that contains one of: (1) a CIM DateTime formated string (e.g. | |
DateTime (time_t t, UInt32 microseconds=0) | |
Create a DateTime object that represents the given time. | |
DateTime (int year, int month, int day, int hour=0, int minute=0, int second=0, UInt32 microsecond=0, ETimeOffset timeOffset=E_LOCAL_TIME) | |
Create a new DateTime object that represent the given date and time. | |
~DateTime () | |
Destructor. | |
int | getHour (ETimeOffset timeOffset=E_LOCAL_TIME) const |
Get the hour of the day for this DateTime object 0-23. | |
int | getMinute (ETimeOffset timeOffset=E_LOCAL_TIME) const |
Get the minute of the hour for this DateTime object 0-59. | |
int | getSecond (ETimeOffset timeOffset=E_LOCAL_TIME) const |
Get the second of the minute for this DateTime object normally in the range 0-59, but can be up to 60 to allow for leap seconds. | |
UInt32 | getMicrosecond () const |
Get the microsecond of the second for this DateTime object. | |
int | getDay (ETimeOffset timeOffset=E_LOCAL_TIME) const |
Get the day of the month (1-31). | |
int | getDow (ETimeOffset timeOffset=E_LOCAL_TIME) const |
int | getMonth (ETimeOffset timeOffset=E_LOCAL_TIME) const |
int | getYear (ETimeOffset timeOffset=E_LOCAL_TIME) const |
time_t | get () const |
void | setHour (int hour, ETimeOffset timeOffset=E_LOCAL_TIME) |
Set the hour component of this DateTime object. | |
void | setMinute (int minute, ETimeOffset timeOffset=E_LOCAL_TIME) |
Set the minute component of this DateTime object. | |
void | setSecond (int second, ETimeOffset timeOffset=E_LOCAL_TIME) |
Set the second component of this DateTime object. | |
void | setMicrosecond (UInt32 microsecond) |
Set the microsecond component of this DateTime object. | |
void | setTime (int hour, int minute, int second, ETimeOffset timeOffset=E_LOCAL_TIME) |
Set the time component of this DateTime object. | |
void | setDay (int day, ETimeOffset timeOffset=E_LOCAL_TIME) |
Set the day component of this DateTime object. | |
void | setMonth (int month, ETimeOffset timeOffset=E_LOCAL_TIME) |
Set the month component of this DateTime object. | |
void | setYear (int year, ETimeOffset timeOffset=E_LOCAL_TIME) |
Set the year component of this DateTime object. | |
void | set (time_t t, UInt32 microseconds=0) |
Set this DateTime object with a time_t value. | |
void | set (int year, int month, int day, int hour, int minute, int second, UInt32 microseconds, ETimeOffset timeOffset=E_LOCAL_TIME) |
Set the date and time for this DateTime. | |
void | setToCurrent () |
Set this DateTime to the current system time. | |
void | addDays (int days) |
Add days to the date represented by this object. | |
void | addWeeks (int weeks) |
Add week to the date represented by this object. | |
void | addMonths (int months) |
Add months to the date represented by this object. | |
void | addYears (int years) |
Add years to the date represent by this object. | |
void | addSeconds (long seconds) |
Add seconds to the date represented by this object. | |
void | addMinutes (long minutes) |
Add minutes to the date represented by this object. | |
void | addMicroseconds (long microseconds) |
Add microseconds to the date represented by this object. | |
void | addMilliseconds (long milliseconds) |
Add milliseconds to the date represented by this object. | |
void | addHours (long hours) |
Add hours to the date represented by this object. | |
bool | operator< (const DateTime &tm) const |
Less than operator. | |
bool | operator> (const DateTime &tm) const |
Greater than operator. | |
bool | operator== (const DateTime &tm) const |
Equality operator. | |
bool | operator!= (const DateTime &tm) const |
Inequality operator. | |
bool | operator<= (const DateTime &tm) const |
Less than or equal operator. | |
bool | operator>= (const DateTime &tm) const |
Greate than or equal operator. | |
DateTime & | operator+= (long seconds) |
Add a given number of seconds to this DateTime object. | |
DateTime & | operator-= (long seconds) |
Subtract a given number of seconds from this DateTime object. | |
String | toString (ETimeOffset timeOffset=E_LOCAL_TIME) const |
String | toString (char const *format, ETimeOffset timeOffset=E_LOCAL_TIME) const |
String | toStringGMT () const |
This is the same as toString(E_UTC_TIME). | |
Int16 | toLocal (struct tm &tt) const |
Converts date/time specified by *this to local time, stored in tt as per the C localtime function, and returns the corresponding GMT offset in minutes. | |
Static Public Member Functions | |
static Int16 | getGMTOffsetMinutesNow () |
Returns the GMT offset (number of minutes) of the system's timezone at the current moment. | |
static DateTime | getCurrent () |
Gets a DateTime instance set to the current system time. | |
Static Public Attributes | |
static char const | DEFAULT_FORMAT [] = "%c" |
A default date/time format to use with toString(). | |
Private Member Functions | |
tm | getTm (ETimeOffset timeOffset) const |
void | setTime (tm &tmarg, ETimeOffset timeOffset) |
Static Private Member Functions | |
static Int16 | localTimeAndOffset (time_t t, struct tm &tt) |
Private Attributes | |
time_t | m_time |
UInt32 | m_microseconds |
It allows easy date/time adjustment, date/time arithmetic and comparison. All functions which operate on a time_t are based on seconds since the Epoch, and the timezone is irrelevant. DateTime cannot represent dates before the Epoch (00:00:00 UTC, January 1, 1970), and the upper limit is system dependent. On a system where time_t is 32-bits, the latest date that can be represented is Mon Jan 18 20:14:07 2038. If time_t is 64-bits, then it's a date so far in the future, that the sun will probably turn into a black hole before then. (About 500 billion years.) If an invalid time is created, then get() will return time_t(-1), and the DateTime represented will be 1 second before the Epoch (23:59:59 UTC, December 31, 1969)
If the non-standard function timegm() is available, it will be used, otherwise this class' implementation relies on the global variable timezone (from time.h) which reflects the system's timezone.
For constructor or setter member functions, if parameter values are outside their legal interval, they will be normalized (so that, e.g., 40 October is changed into 9 November).
Definition at line 77 of file OW_DateTime.hpp.
|
The values of this enum are passed to various functions to as a flag to indicate the timezone context desired. E_LOCAL_TIME means the operation will apply the local system timezone (which may include an offset for daylight saving time). E_UTC_TIME means the operation will apply to UTC (or GMT) time. Definition at line 87 of file OW_DateTime.hpp. |
|
Create a new DateTime object that represents the Epoch (00:00:00 UTC, January 1, 1970).
Definition at line 129 of file OW_DateTime.cpp. |
|
Create a new DateTime object from a string that contains one of: (1) a CIM DateTime formated string (e.g. "19980525133015.000000-300") (2) a ctime() formatted string (e.g. "Wed Jun 30 21:49:08 1993") The current local timezone is assumed. (3) a free-form date which must have a month, day, year, and time. Optional fields are a weekday, and timezone, and the seconds subfield of the time field. There are no restrictions on the ordering of fields, with the exception of the day of month and year. Assumptions made: The first free-standing number found is assumed to be the day of month. The second is the day of year. Fields: Month (required) The month field may be one of the three-letter English abbreviations (eg. Jan, Feb, Mar, etc), or the full English month name (eg. January, February, March, etc). Note that they are case sensitive, and only the first character is uppercase. Day of month (required) A number. Currently, the first free-standing number found is assumed to be the day of month. Year (required) A number. Currently, the second free-standing number found is assumed to be the year. Time (required) The hours, minutes, and optionally seconds of the time. It is in the form HH:MM or HH:MM:SS. The hour is expressed in the 24 hour format (eg. 4pm would be hour 16). Day of week (optional) The day of week field may be one of the three-letter English abbreviations (eg. Sun, Mon, Tue, etc), or the full English day name (eg. Sunday, Monday, Tuesday, etc). Note that they are case sensitive, and only the first character is uppercase. Timezone (optional) The timezone of the date. The date and time will be transformed into UTC by this time zone. If the time zone is not present, then the date is assumed to be in local time. The following time zones are recognized (case sensitive): UTC, GMT, BST, IST, WET, WEST, CET, CEST, EET, EEST, MSK, MSD, AST, ADT, EST, EDT, ET, CST, CDT, CT, MST, MDT, MT, PST, PDT, PT, HST, AKST, AKDT, WST, and single letters [A-Z] Timezones ET, CT, MT, and PT are all assumed to be standard (not daylight) time. NOTE: Some Australian time zones (EST, and CST), which conflict with US time zones are assumed to be in the US. Valid Examples of free-form date strings: Thu Jan 29 11:02:42 MST 2004 Oct 3 17:52:56 EDT 1998 5:41:26 PDT Aug 15 1984 7 November 2003 13:35:03 GMT Monday May 1 8:27:39 UTC 2003 June 1 23:49 2003 Note that DateTime cannot hold an interval, so you cannot construct one from an CIM DateTime interval. If str is a CIM DateTime, the timezone is part of the string and will be honored. Otherwise, if str is a ctime() formatted string, the current C timezone will be used.
Definition at line 750 of file OW_DateTime.cpp. References E_UTC_TIME, i, OW_NAMESPACE::String::length(), set(), and OW_NAMESPACE::validateRanges(). |
|
Create a DateTime object that represents the given time.
Definition at line 972 of file OW_DateTime.cpp. |
|
Create a new DateTime object that represent the given date and time.
Definition at line 978 of file OW_DateTime.cpp. References set(). |
|
Destructor.
Definition at line 984 of file OW_DateTime.cpp. |
|
Add days to the date represented by this object.
Definition at line 1218 of file OW_DateTime.cpp. References E_UTC_TIME, getTm(), and setTime(). |
|
Add hours to the date represented by this object.
Definition at line 408 of file OW_DateTime.hpp. |
|
Add microseconds to the date represented by this object.
Definition at line 391 of file OW_DateTime.hpp. |
|
Add milliseconds to the date represented by this object.
Definition at line 400 of file OW_DateTime.hpp. |
|
Add minutes to the date represented by this object.
Definition at line 384 of file OW_DateTime.hpp. Referenced by OW_NAMESPACE::LocalAuthentication::cleanupStaleEntries(), and OW_NAMESPACE::CIMOMEnvironment::unloadReqHandlers(). |
|
Add months to the date represented by this object.
Definition at line 1234 of file OW_DateTime.cpp. References E_UTC_TIME, getTm(), and setTime(). |
|
Add seconds to the date represented by this object.
Definition at line 376 of file OW_DateTime.hpp. |
|
Add week to the date represented by this object.
Definition at line 355 of file OW_DateTime.hpp. |
|
Add years to the date represent by this object.
Definition at line 1226 of file OW_DateTime.cpp. References E_UTC_TIME, getTm(), and setTime(). |
|
Definition at line 1101 of file OW_DateTime.cpp. References m_time. Referenced by OW_NAMESPACE::PollingManagerThread::addPolledProvider(), OW_NAMESPACE::PollingManagerThread::calcSleepTime(), OW_NAMESPACE::DigestAuthentication::generateNewNonce(), OW_NAMESPACE::operator-(), OW_NAMESPACE::PollingManagerThread::processTriggers(), and OW_NAMESPACE::PollingManagerThread::TriggerRunner::run(). |
|
Gets a DateTime instance set to the current system time.
Definition at line 1322 of file OW_DateTime.cpp. References setToCurrent(). Referenced by OW_NAMESPACE::IndicationRepLayerImpl::createClass(), OW_NAMESPACE::IndicationRepLayerImpl::createInstance(), OW_NAMESPACE::IndicationRepLayerImpl::deleteClass(), OW_NAMESPACE::IndicationRepLayerImpl::deleteInstance(), OW_NAMESPACE::IndicationRepLayerImpl::getInstance(), OW_NAMESPACE::IndicationRepLayerImpl::modifyClass(), OW_NAMESPACE::IndicationRepLayerImpl::modifyInstance(), and OW_NAMESPACE::LifecycleIndicationPoller::poll(). |
|
Get the day of the month (1-31).
Definition at line 1077 of file OW_DateTime.cpp. References getTm(). |
|
Definition at line 1083 of file OW_DateTime.cpp. References getTm(). |
|
Returns the GMT offset (number of minutes) of the system's timezone at the current moment. Replacement for getGMTOffset(), if anyone is using it. Definition at line 539 of file OW_DateTime.hpp. References localTimeAndOffset(). |
|
Get the hour of the day for this DateTime object 0-23.
Definition at line 1053 of file OW_DateTime.cpp. References getTm(). |
|
Get the microsecond of the second for this DateTime object. In the range 0..999999. There are 1 million (1000000) microseconds per second.
Definition at line 1071 of file OW_DateTime.cpp. References m_microseconds. Referenced by OW_NAMESPACE::CIMDateTime::CIMDateTime(), OW_NAMESPACE::operator-(), OW_NAMESPACE::SocketBaseImpl::read(), and OW_NAMESPACE::SocketBaseImpl::write(). |
|
Get the minute of the hour for this DateTime object 0-59.
Definition at line 1059 of file OW_DateTime.cpp. References getTm(). |
|
Definition at line 1089 of file OW_DateTime.cpp. References getTm(). |
|
Get the second of the minute for this DateTime object normally in the range 0-59, but can be up to 60 to allow for leap seconds.
Definition at line 1065 of file OW_DateTime.cpp. References getTm(). |
|
Definition at line 989 of file OW_DateTime.cpp. References E_LOCAL_TIME, gmtime_r(), localtime_r(), and m_time. Referenced by addDays(), addMonths(), addYears(), getDay(), getDow(), getHour(), getMinute(), getMonth(), getSecond(), getYear(), setDay(), setHour(), setMinute(), setMonth(), setSecond(), setTime(), setYear(), and toString(). |
|
Definition at line 1095 of file OW_DateTime.cpp. References getTm(). |
|
Definition at line 1273 of file OW_DateTime.cpp. References gmtime_r(), localtime_r(), and OW_THROW. Referenced by getGMTOffsetMinutesNow(), and toLocal(). |
|
Inequality operator.
Definition at line 445 of file OW_DateTime.hpp. |
|
Add a given number of seconds to this DateTime object.
Definition at line 474 of file OW_DateTime.hpp. References OWBI1::addSeconds(). |
|
Subtract a given number of seconds from this DateTime object.
Definition at line 484 of file OW_DateTime.hpp. References OWBI1::addSeconds(). |
|
Less than operator.
Definition at line 414 of file OW_DateTime.hpp. References m_microseconds, and m_time. |
|
Less than or equal operator.
Definition at line 455 of file OW_DateTime.hpp. |
|
Equality operator.
Definition at line 436 of file OW_DateTime.hpp. References m_microseconds, and m_time. |
|
Greater than operator.
Definition at line 427 of file OW_DateTime.hpp. |
|
Greate than or equal operator.
Definition at line 465 of file OW_DateTime.hpp. |
|
Set the date and time for this DateTime.
Definition at line 1180 of file OW_DateTime.cpp. References E_UTC_TIME, m_microseconds, and setTime(). |
|
Set this DateTime object with a time_t value.
Definition at line 1308 of file OW_DateTime.cpp. References m_microseconds, m_time, and OW_THROW. Referenced by DateTime(). |
|
Set the day component of this DateTime object.
Definition at line 1151 of file OW_DateTime.cpp. |
|
Set the hour component of this DateTime object.
Definition at line 1107 of file OW_DateTime.cpp. |
|
Set the microsecond component of this DateTime object.
Definition at line 1131 of file OW_DateTime.cpp. References m_microseconds, and OW_THROW. |
|
Set the minute component of this DateTime object.
Definition at line 1115 of file OW_DateTime.cpp. |
|
Set the month component of this DateTime object.
Definition at line 1159 of file OW_DateTime.cpp. |
|
Set the second component of this DateTime object.
Definition at line 1123 of file OW_DateTime.cpp. |
|
Definition at line 1007 of file OW_DateTime.cpp. References E_LOCAL_TIME, m_time, OW_THROW, and toString(). |
|
Set the time component of this DateTime object.
Definition at line 1141 of file OW_DateTime.cpp. References getTm(). Referenced by addDays(), addMonths(), addYears(), set(), setDay(), setHour(), setMinute(), setMonth(), setSecond(), and setYear(). |
|
|
Set the year component of this DateTime object.
Definition at line 1172 of file OW_DateTime.cpp. |
|
Converts date/time specified by *this to local time, stored in tt as per the C localtime function, and returns the corresponding GMT offset in minutes.
Definition at line 551 of file OW_DateTime.hpp. References localTimeAndOffset(). Referenced by OW_NAMESPACE::CIMDateTime::CIMDateTime(). |
|
Definition at line 1252 of file OW_DateTime.cpp. References OW_NAMESPACE::ExceptionDetail::BUFSZ, and getTm(). |
|
Definition at line 1242 of file OW_DateTime.cpp. Referenced by OW_NAMESPACE::HTTPUtils::date(), OW_NAMESPACE::SocketBaseImpl::read(), setTime(), toStringGMT(), and OW_NAMESPACE::SocketBaseImpl::write(). |
|
This is the same as toString(E_UTC_TIME). This function is deprecated and exists for backward compatibility purposes. Definition at line 1267 of file OW_DateTime.cpp. References E_UTC_TIME, and toString(). |
|
A default date/time format to use with toString(). The value is "%c", which is "The preferred date and time representation for the current locale." Definition at line 514 of file OW_DateTime.hpp. |
|
Definition at line 563 of file OW_DateTime.hpp. Referenced by getMicrosecond(), operator<(), operator==(), set(), setMicrosecond(), and setToCurrent(). |
|
Definition at line 562 of file OW_DateTime.hpp. Referenced by get(), getTm(), operator<(), operator==(), set(), setTime(), and setToCurrent(). |