Utility class that requires a string as per the following format: http://en.wikipedia.org/wiki/ISO_8601 to construct an instance and provides some commmonly used parts like year, month, hour etc. in different data types and formats. All dates are in the local timezone unless otherwise specified.
#include <utility/YiDateTime.h>
| CYIDateTime::CYIDateTime |
( |
const CYIString & |
rDateTimeString | ) |
|
Creates a DateTime object from a string that contains date and time information as per the ISO 8601 format (link at top).
| CYIDateTime::CYIDateTime |
( |
const time_t |
epochTime | ) |
|
Creates a DateTime object from Epoch time (seconds since January 1st, 1970 00:00:00 UTC).
- Note
- If epochTime is less than 0 the date time object will be constructed as January 1, 1970 00:00:00 UTC.
| CYIDateTime::CYIDateTime |
( |
| ) |
|
Creates a DateTime object using the current local date and time.
| virtual CYIDateTime::~CYIDateTime |
( |
| ) |
|
|
virtual |
Destroys the DateTime object.
| bool CYIDateTime::AddDays |
( |
const int32_t |
nDays | ) |
|
Adds days to the current CYIDateTime object, maximum nDays is maximum int32_t value divided by 60. Returns false without modifying the date if the resultant date would be before January 1, 1970 00:00:00 UTC or after the maximum epoch (maximum time_t) value for the current system.
| bool CYIDateTime::AddHours |
( |
const int32_t |
nHours | ) |
|
Adds hours to the current CYIDateTime object, maximum nHours is maximum int32_t value divided by 60. Returns false without modifying the date if the resultant date would be before January 1, 1970 00:00:00 UTC or after the maximum epoch (maximum time_t) value for the current system.
| bool CYIDateTime::AddMinutes |
( |
const int32_t |
nMinutes | ) |
|
Adds minutes to the current CYIDateTime object, maximum nMinutes is maximum int32_t value divided by 60. Returns false without modifying the date if the resultant date would be before January 1, 1970 00:00:00 UTC or after the maximum epoch time that can be represented by time_t for the current system.
| bool CYIDateTime::AddMonths |
( |
const int32_t |
nMonths | ) |
|
Adds months to the current CYIDateTime object, takes into account variation of days in month and leap years. Returns false without modifying the date if the resultant date would be before January 1, 1970 00:00:00 UTC or after the maximum epoch (maximum time_t) value for the current system.
| bool CYIDateTime::AddSeconds |
( |
const int32_t |
nSeconds | ) |
|
Adds seconds to the current CYIDateTime object. Returns false without modifying the date if the resultant date would be before January 1, 1970 00:00:00 UTC or after the maximum epoch (maximum time_t) value for the current system.
| bool CYIDateTime::AddYears |
( |
const int32_t |
nYears | ) |
|
Adds years to the current CYIDateTime object, maximum nYears is maximum int32_t value divided by 60. Returns false without modifying the date if the resultant date would be before January 1, 1970 00:00:00 UTC or after the maximum epoch (maximum time_t) value for the current system.
Prints the date held by this object using the specified format, and returns the result as a CYIString. Be weary of portability issues with this function as it depends on strftime (which has different behavior on different platforms).
| CYIString CYIDateTime::FormatString |
( |
| ) |
const |
Prints the date held by this object using the ISO 8601 format, and returns the result as a CYIString.
Returns the system's current date and time. Equivalent to creating an instance of CYIDateTime without any arguments.
| uint32_t CYIDateTime::GetDay |
( |
| ) |
const |
Returns the day in the range [1,31].
| uint32_t CYIDateTime::GetDayOfWeek |
( |
| ) |
const |
Returns the index of the day of the week (locale-dependent).
The index starts at 0 for Sunday.
| CYIString CYIDateTime::GetDayOfWeekName |
( |
| ) |
const |
Returns the full name of the day (locale-dependent).
Example results: Sunday, Monday, Tuesday
| CYIString CYIDateTime::GetDayOfWeekShortName |
( |
| ) |
const |
Returns the short name of the day (locale-dependent).
Example results: Sun, Mon, Tue
| static uint32_t CYIDateTime::GetDaysInMonth |
( |
const uint32_t |
uMonth, |
|
|
const uint32_t |
uYear |
|
) |
| |
|
static |
Given a year and month returns the number of days in the month.
- Note
- uMonth is zero based.
| static double CYIDateTime::GetDifferenceBetween |
( |
const CYIDateTime & |
rFirstDateTime, |
|
|
const CYIDateTime & |
rSecondDateTime |
|
) |
| |
|
static |
Calculates and returns the difference, in seconds, between the two provided CYIDateTime's. If the second CYIDateTime is chronologically before the first CYIDateTime, a negative value is returned. If either of the objects contain an invalid time, the result of this function is undefined. This function is to be a replacement for the difftime() function from <time.h> (though the 'end' and 'beginning' fields are reversed).
| time_t CYIDateTime::GetEpochTime |
( |
| ) |
const |
Generates and returns the epoch time for this class. This is defined as the number of seconds between this date and January 1st 1970 UTC. Returns -1 if the time defined by this object is invalid.
| uint32_t CYIDateTime::GetHour |
( |
| ) |
const |
Returns the hour in the range [0,23].
| uint32_t CYIDateTime::GetMinute |
( |
| ) |
const |
Returns the minute in the range [0,59].
| uint32_t CYIDateTime::GetMonth |
( |
| ) |
const |
Returns the month in the range [0,11].
| CYIString CYIDateTime::GetMonthName |
( |
| ) |
const |
Returns the full name of the month (locale-dependent).
Example results: January, February, March
| CYIString CYIDateTime::GetMonthShortName |
( |
| ) |
const |
Returns the short name of the month (locale-dependent).
Example results: Jan, Feb, Mar
| uint32_t CYIDateTime::GetSecond |
( |
| ) |
const |
Returns the second in the range [0,61].
- Note
- The range goes to 61 rather than 59 to accomodate for leap seconds in some systems.
| double CYIDateTime::GetSecondsUntil |
( |
const CYIDateTime & |
rTargetDateTime | ) |
const |
Calculates and returns the difference, in seconds, between this object and the provided CYIDateTime. If the provided CYIDateTime is chronologically before this CYIDateTime, this function returns a negative value. If the provided date contains an invalid date or if this object contains an invalid date, the result of this function is undefined.
| uint32_t CYIDateTime::GetYear |
( |
| ) |
const |
Returns the year in the range [1970,3000].
| static bool CYIDateTime::IsLeapYear |
( |
const uint32_t |
uYear | ) |
|
|
static |
Given a year returns true if the year is a leap year, false otherwise.
| bool CYIDateTime::IsValid |
( |
| ) |
const |
Returns true if this object contains a valid date.
| virtual bool CYIDateTime::operator!= |
( |
const CYIDateTime & |
rOther | ) |
const |
|
virtual |
| virtual bool CYIDateTime::operator+= |
( |
const CYIDateTime & |
rOther | ) |
|
|
virtual |
| virtual bool CYIDateTime::operator-= |
( |
const CYIDateTime & |
rOther | ) |
|
|
virtual |
| virtual bool CYIDateTime::operator< |
( |
const CYIDateTime & |
rOther | ) |
const |
|
virtual |
| virtual bool CYIDateTime::operator<= |
( |
const CYIDateTime & |
rOther | ) |
const |
|
virtual |
| virtual bool CYIDateTime::operator== |
( |
const CYIDateTime & |
rOther | ) |
const |
|
virtual |
| virtual bool CYIDateTime::operator> |
( |
const CYIDateTime & |
rOther | ) |
const |
|
virtual |
| virtual bool CYIDateTime::operator>= |
( |
const CYIDateTime & |
rOther | ) |
const |
|
virtual |
| bool CYIDateTime::SetDateTime |
( |
const CYIString & |
rDateTimeString | ) |
|
Updates the fields of the DateTime object based on information provided as per ISO 8601 (link at top) via rDateTimeString parameter. Returns true if operation succeeded, false otherwise.
| bool CYIDateTime::SetDateTimeRFC1123 |
( |
const CYIString & |
rDateTimeString | ) |
|
Updates the fields of the DateTime object based on information provided as per RFC 1123 via rDateTimeString parameter. Returns true if operation succeeded, false otherwise.
| bool CYIDateTime::SetDay |
( |
uint32_t |
uDay | ) |
|
Sets the day, must be in the range [1,31].
| bool CYIDateTime::SetEpochTime |
( |
const time_t |
epochTime | ) |
|
Sets the date time to a given epoch time. This is defined as the number of seconds between this date and January 1st 1970 UTC.
Returns false if epochTime represents a time before January 1st 1970 UTC (if epochTime is negative).
| bool CYIDateTime::SetHour |
( |
uint32_t |
uHour | ) |
|
Sets the hour, must be in the range [0,23].
| bool CYIDateTime::SetMinute |
( |
uint32_t |
uMinute | ) |
|
Sets the minute, must be in the range [0,59].
| bool CYIDateTime::SetMonth |
( |
uint32_t |
uMonth | ) |
|
Sets the month, /a uMonth must be in the range [0,11].
- Note
- If the current day is greater than the number of days in uMonth the month and day will be adjusted.
| bool CYIDateTime::SetSecond |
( |
uint32_t |
uSecond | ) |
|
Sets the second, must be in the range [0,61].
- Note
- The range goes to 61 rather than 59 to accomodate for leap seconds in some systems.
| bool CYIDateTime::SetYear |
( |
uint32_t |
uYear | ) |
|
Sets the year, must be in the range [1970,3000].
The documentation for this class was generated from the following file: