#include <DateTime.hpp>
Collaboration diagram for Ionflux::Tools::DateTime:
Public Member Functions | |
DateTime () | |
Constructor. | |
DateTime (time_t initTime) | |
Constructor. | |
DateTime (TimeTicks initTime) | |
Constructor. | |
DateTime (struct tm initTime) | |
Constructor. | |
DateTime (const std::string &initTime) | |
Constructor. | |
DateTime (const DateTime &initTime) | |
Constructor. | |
DateTime (int initYear, int initMonth, int initDay, int initHour, int initMinute, int initSecond) | |
Constructor. | |
virtual | ~DateTime () |
Destructor. | |
virtual void | setTime (time_t newTime) |
Set time. | |
virtual void | setTime (TimeTicks newTime) |
Set time. | |
virtual void | setTime (tm newTime) |
Set time. | |
virtual void | setTime (const std::string &newTime) |
Set time. | |
virtual void | setTime (const DateTime &newTime) |
Set time. | |
virtual void | setTime (int newYear, int newMonth, int newDay, int newHour, int newMinute, int newSecond) |
Set time. | |
virtual void | setLocalTime (const DateTime &newTime, bool newDSTState) |
Set local time. | |
virtual void | setLocalTime (const std::string &newTime, bool newDSTState) |
Set local time. | |
virtual void | setLocalTime (int newYear, int newMonth, int newDay, int newHour, int newMinute, int newSecond, bool newDSTState) |
Set local time. | |
virtual void | setLocalTime (const DateTime &newTime) |
Set local time. | |
virtual void | setLocalTime (const std::string &newTime) |
Set local time. | |
virtual void | setLocalTime (int newYear, int newMonth, int newDay, int newHour, int newMinute, int newSecond) |
Set local time. | |
virtual void | setHMS (int newHour, int newMinute, int newSecond) |
Set time of day. | |
virtual void | setHMS (const std::string &newTime) |
Set time of day. | |
virtual void | setHMS (const DateTime &sourceTime) |
Set time of day. | |
virtual void | setLocalHMS (int newHour, int newMinute, int newSecond, bool newDSTState) |
Set time of day. | |
virtual void | setLocalHMS (const std::string &newTime, bool newDSTState) |
Set time of day. | |
virtual void | setLocalHMS (const DateTime &sourceTime, bool newDSTState) |
Set time of day. | |
virtual void | setLocalHMS (int newHour, int newMinute, int newSecond) |
Set time of day. | |
virtual void | setLocalHMS (const std::string &newTime) |
Set time of day. | |
virtual void | setLocalHMS (const DateTime &sourceTime) |
Set time of day. | |
virtual DateTime & | shift (int shiftSeconds) |
Shift DateTime. | |
virtual TimeTicks | diff (const DateTime &diffTime) const |
Calculate DateTime difference. | |
virtual void | setTimeZone (const TimeZone *newTimeZone, bool newManage) |
Set time zone. | |
virtual void | setTimeZone (const std::string &newTimeZone) |
Set time zone. | |
virtual int | compareHMS (int otherHour, int otherMinute, int otherSecond) |
Compare time of day. | |
virtual int | compareHMS (const DateTime &otherTime) |
Compare time of day. | |
virtual int | compareHMS (const std::string &otherTime) |
Compare time of day. | |
virtual int | compareDay (const DateTime &otherTime) |
Compare day. | |
virtual DateTime | getUTC () |
Get UTC representation. | |
virtual TimeTicks | getTicks () const |
Get UTC seconds. | |
virtual time_t | getTime () const |
Get POSIX timestamp. | |
virtual tm | getBrokenTime () const |
Get broken down calendar time. | |
virtual std::string | getTimestamp () |
Get timestamp. | |
virtual std::string | getHMS () |
Get time of day. | |
virtual Year | getYear () const |
Get year. | |
virtual int | getMonth () const |
Get month. | |
virtual int | getDay () const |
Get day. | |
virtual int | getHour () const |
Get hour. | |
virtual int | getMinute () const |
Get minute. | |
virtual int | getSecond () const |
Get second. | |
virtual int | getDayOfWeek () const |
Get day of week. | |
virtual int | getDayOfYear () const |
Get day of year. | |
virtual std::string | getDayOfWeekName () const |
Get day of week name. | |
virtual std::string | getDayOfWeekShortName () const |
Get short day of week name. | |
virtual std::string | getMonthName () const |
Get month name. | |
virtual std::string | getMonthShortName () const |
Get month short name. | |
virtual const TimeZone * | getTimeZone () const |
Get time zone. | |
virtual std::string | getTimeZoneName () const |
Get name of time zone. | |
virtual std::string | getTimeZoneAliases () const |
Get time zone aliases. | |
virtual bool | isDST () const |
Get DST state. | |
virtual int | getUTCOffset () const |
Get UTC offset. | |
virtual std::string | getRFCTimestamp () const |
Get RFC 822 timestamp. | |
virtual DateTime & | operator= (const DateTime &newTime) |
Assignment operator. | |
virtual DateTime & | operator+= (TimeTicks seconds) |
Add operator. | |
virtual DateTime & | operator-= (TimeTicks seconds) |
Substract operator. | |
virtual TimeTicks | operator- (const DateTime &diffTime) const |
Substract operator. | |
virtual bool | operator== (const DateTime &compTime) const |
Comparison operator. | |
virtual bool | operator> (const DateTime &compTime) const |
Comparison operator. | |
virtual bool | operator< (const DateTime &compTime) const |
Comparison operator. | |
virtual bool | operator>= (const DateTime &compTime) const |
Comparison operator. | |
virtual bool | operator<= (const DateTime &compTime) const |
Comparison operator. | |
Static Public Member Functions | |
static void | makeBrokenTime (time_t *source, tm *target) |
Create broken down calendar time. | |
static Year | countLeapYears (Year limit) |
Count leap years. | |
static bool | isLeapYear (Year checkYear) |
Check leap year status. | |
static DateTime | getNth (Year targetYear, int targetMonth, int targetWeekDay, int n) |
Get n-th occurence of a day of week in a month. | |
static bool | isTime (const std::string &checkTime) |
Check time. | |
static bool | isDate (const std::string &checkDate) |
Check date. | |
static bool | isDatetime (const std::string &checkDatetime) |
Check datetime. | |
Static Public Attributes | |
static const std::string | TIMESTAMP_DATE_SEP = "-" |
Timestamp date separator. | |
static const std::string | TIMESTAMP_TIME_SEP = ":" |
Timestamp time separator. | |
static const std::string | TIMESTAMP_DATETIME_SEP = " " |
Timestamp datetime separator. | |
static const int | NUM_DAYS [] |
Number of days up to the beginning of the first day of month j + 1 for non-leap years (NUM_DAYS[0. | |
static const int | LEAP_MONTH = 2 |
Leap month. | |
static const TimeTicks | POSIX_EPOCH = 62135596800LL |
Start tick count for POSIX epoch. | |
static const TimeTicks | TICKS_400Y = 12622780800LL |
Leap year neutral tick step: 400 years. | |
static const TimeTicks | TICKS_100Y = 3155673600LL |
Leap year neutral tick step: 100 years. | |
static const TimeTicks | TICKS_4Y = 126230400LL |
Leap year neutral tick step: 4 years. | |
static const TimeTicks | TICKS_3Y = 94608000LL |
Leap year neutral tick step: 3 years. | |
static const TimeTicks | TICKS_1Y = 31536000LL |
Leap year neutral tick step: 1 year. | |
static const TimeTicks | TICKS_1D = 86400LL |
Ticks per day. | |
static const TimeTicks | REF_SUNDAY = 63223891200LL |
Reference ticks of a sunday. | |
static const char * | WEEKDAY_NAME [] |
Weekday names. | |
static const char * | WEEKDAY_NAME_SHORT [] |
Weekday names (short). | |
static const char * | MONTH_NAME [] |
Month names. | |
static const char * | MONTH_NAME_SHORT [] |
Month names (short). | |
static const TimeZone | TZ_UTC |
Time zone: UTC. | |
static const TimeZone | TZ_UTC_P0100 |
Time zone: UTC+0100. | |
static const TimeZone | TZ_UTC_P0200 |
Time zone: UTC+0200. | |
static const TimeZone | TZ_UTC_P0300 |
Time zone: UTC+0300. | |
static const TimeZone | TZ_UTC_P0330 |
Time zone: UTC+0330. | |
static const TimeZone | TZ_UTC_P0400 |
Time zone: UTC+0400. | |
static const TimeZone | TZ_UTC_P0430 |
Time zone: UTC+0430. | |
static const TimeZone | TZ_UTC_P0500 |
Time zone: UTC+0500. | |
static const TimeZone | TZ_UTC_P0530 |
Time zone: UTC+0530. | |
static const TimeZone | TZ_UTC_P0545 |
Time zone: UTC+0545. | |
static const TimeZone | TZ_UTC_P0600 |
Time zone: UTC+0600. | |
static const TimeZone | TZ_UTC_P0630 |
Time zone: UTC+0630. | |
static const TimeZone | TZ_UTC_P0700 |
Time zone: UTC+0700. | |
static const TimeZone | TZ_UTC_P0800 |
Time zone: UTC+0800. | |
static const TimeZone | TZ_UTC_P0900 |
Time zone: UTC+0900. | |
static const TimeZone | TZ_UTC_P0930 |
Time zone: UTC+0930. | |
static const TimeZone | TZ_UTC_P1000 |
Time zone: UTC+1000. | |
static const TimeZone | TZ_UTC_P1100 |
Time zone: UTC+1100. | |
static const TimeZone | TZ_UTC_P1200 |
Time zone: UTC+1100. | |
static const TimeZone | TZ_UTC_M0100 |
Time zone: UTC-0100. | |
static const TimeZone | TZ_UTC_M0200 |
Time zone: UTC-0200. | |
static const TimeZone | TZ_UTC_M0300 |
Time zone: UTC-0300. | |
static const TimeZone | TZ_UTC_M0400 |
Time zone: UTC-0400. | |
static const TimeZone | TZ_UTC_M0500 |
Time zone: UTC-0500. | |
static const TimeZone | TZ_UTC_M0600 |
Time zone: UTC-0600. | |
static const TimeZone | TZ_UTC_M0700 |
Time zone: UTC-0700. | |
static const TimeZone | TZ_UTC_M0800 |
Time zone: UTC-0800. | |
static const TimeZone | TZ_UTC_M0900 |
Time zone: UTC-0900. | |
static const TimeZone | TZ_UTC_M1000 |
Time zone: UTC-1000. | |
static const TimeZone | TZ_UTC_M1100 |
Time zone: UTC-1100. | |
static const TimeZone | TZ_UTC_M1200 |
Time zone: UTC-1100. | |
static const TimeZone | TZ_GMT |
Time zone: GMT. | |
static const TimeZone | TZ_EUROPE_WESTERN |
Time zone: Europe/Western (WET/WEST). | |
static const TimeZone | TZ_EUROPE_CENTRAL |
Time zone: Europe/Central (CET/CEST). | |
static const TimeZone | TZ_EUROPE_EASTERN |
Time zone: Europe/Eastern (EET/EEST). | |
static const TimeZone | TZ_UK |
Time zone: United Kingdom (WET/BST). | |
static const TimeZone | TZ_USA_EASTERN |
Time zone: USA/Eastern (EST/EDT). | |
static const TimeZone | TZ_USA_CENTRAL |
Time zone: USA/Central (CST/CDT). | |
static const TimeZone | TZ_USA_MOUNTAIN |
Time zone: USA/Mountain (MST/MDT). | |
static const TimeZone | TZ_USA_PACIFIC |
Time zone: USA/Pacific (PST/PDT). | |
static const TimeZone | TZ_USA_ALASKA |
Time zone: USA/Alaska (AKST/AKDT). | |
static const TimeZone | TZ_RUSSIA_WESTERN |
Time zone: Russia/Western (UTC+03). | |
static const TimeZone | TZ_EGYPT |
Time zone: Egypt (UTC+02). | |
Protected Member Functions | |
virtual void | parseTimestamp (const std::string &source) |
Parse a timestamp. | |
virtual std::string | createTimestamp () |
Create a timestamp. | |
virtual void | updateTicks () |
Update ticks from broken down calendar time. | |
virtual void | updateBrokenDownTime (int tickOffset) |
Update broken down calendar time from ticks. | |
virtual void | initTimeZones () |
Initialize default time zones. | |
Protected Attributes | |
TimeTicks | ticks |
Number of UTC seconds since 0001-01-01 00:00:00. | |
std::string | timestamp |
Timestamp (string representation, "YYYY-MM-DD HH:MM:SS"). | |
const TimeZone * | timeZone |
Local time zone. | |
Year | year |
Broken down time: Year. | |
int | month |
Broken down time: Month (1...12). | |
int | day |
Broken down time: Day of month (1...31). | |
int | hour |
Broken down time: Hour (0...23). | |
int | minute |
Broken down time: Minute (0...59). | |
int | second |
Broken down time: Second (0...59). | |
int | weekDay |
Broken down time: Day of week (0...6, where 0 = Sunday). | |
int | yearDay |
Broken down time: Day of year (1...366). | |
bool | dstState |
Broken down time: DST flag. | |
int | utcOffset |
Broken down time: UTC offset (minutes). | |
bool | manageTimeZone |
Time zone memory management flag. | |
std::vector< const TimeZone * > | defaultTimeZones |
Vector of default time zones. |
Date and time wrapper with various manipulation and conversion facilities.
|
Constructor. Construct new DateTime object which will be initialized with the current local time. |
|
Constructor. Construct new DateTime object which will be initialized with the POSIX timestamp passed as an argument.
|
|
Constructor. Construct new DateTime object which will be initialized with the UTC seconds passed as an argument.
|
|
Constructor. Construct new DateTime object which will be initialized with the broken down calendar time passed as an argument.
|
|
Constructor. Construct new DateTime object which will be initialized with the timestamp (string representation, "YYYY-MM-DD HH:MM:SS") passed as an argument.
|
|
Constructor. Construct new DateTime object which will be initialized with another DateTime object.
|
|
Constructor. Construct new DateTime object which will be initialized with the specified date and time.
|
|
Destructor. Destruct DateTime object. |
|
Compare day. Compares day to that of another Datetime.
|
|
Compare time of day. Compares time of day (HH:MM:SS) only, without respect to time zone or DST offsets.
|
|
Compare time of day. Compares time of day (HH:MM:SS) only, without respect to time zone or DST offsets.
|
|
Compare time of day. Compares time of day (HH:MM:SS) only, without respect to time zone or DST offsets.
|
|
Count leap years. Count the number of leap years from 0001-01-01 00:00:00 up to January 1st, 00:00:00 of the specified year.
|
|
Create a timestamp. Create a timestamp in string representation ("YYYY-MM-DD HH:MM:SS").
|
|
Calculate DateTime difference. Calculate the difference (in seconds) of two DateTime objects.
|
|
Get broken down calendar time.
|
|
Get day.
|
|
Get day of week.
|
|
Get day of week name.
|
|
Get short day of week name.
|
|
Get day of year.
|
|
Get time of day. Get time of day in string representation ("HH:MM:SS").
|
|
Get hour.
|
|
Get minute.
|
|
Get month.
|
|
Get month name.
|
|
Get month short name.
|
|
Get n-th occurence of a day of week in a month. Returns the UTC DateTime of the start (00:00:00) of the n-th occurrence of the specified day of week in the specified month of the specified year. If this day is not present in the requested month, the last occurence of that day in the specified month is returned. You can use this to get the last occurence of any day of week within a month by setting n to 5;
|
|
Get RFC 822 timestamp.
|
|
Get second.
|
|
Get UTC seconds. Get datetime as number of UTC seconds since 0001-01-01 00:00:00 (not counting leap seconds).
|
|
Get POSIX timestamp. Get datetime as POSIX timestamp, i.e. number of seconds since the beginning of the POSIX epoch.
|
|
Get timestamp. Get timestamp in string representation ("YYYY-MM-DD HH:MM:SS").
|
|
Get time zone.
|
|
Get time zone aliases. Get a colon (':') separated list of all recognized time zone alias names. These are the names you can use to set the time zone with setTimeZone().
|
|
Get name of time zone.
|
|
Get UTC representation. Get an UTC representation of a datetime.
|
|
Get UTC offset.
|
|
Get year.
|
|
Initialize default time zones.
|
|
Check date. Check whether the specified string represents a date (i.e. has the format "YYYY-MM-DD"). Range checks are performed for month and day, however, it is not checked whether the specified day is actually a valid date.
|
|
Check datetime. Check whether the specified string represents a datetime (i.e. has the format "YYYY-MM-DD[ HH[:MM[:SS]]]"). Range checks are performed for hours, minutes, seconds, month and day, however, it is not checked whether the specified datetime is actually a valid date.
|
|
Get DST state.
|
|
Check leap year status.
Returns
|
|
Check time. Check whether the specified string represents a time of day (i.e. has the format"HH[:MM[:SS]]"). Range checks are performed for hours, minutes and seconds.
|
|
Create broken down calendar time. Creates a broken down calendar time from a POSIX timestamp.
|
|
Add operator.
|
|
Substract operator.
|
|
Substract operator.
|
|
Comparison operator.
|
|
Comparison operator.
|
|
Assignment operator.
|
|
Comparison operator.
|
|
Comparison operator.
|
|
Comparison operator.
|
|
Parse a timestamp. Parse a timestamp in string representation ("YYYY-MM-DD HH:MM:SS").
|
|
Set time of day. Sets the time of day (UTC).
|
|
Set time of day. Sets the time of day (UTC).
|
|
Set time of day. Sets the time of day (UTC).
|
|
Set time of day. Sets the time of day (local time).
|
|
Set time of day. Sets the time of day (local time).
|
|
Set time of day. Sets the time of day (local time).
|
|
Set time of day. Sets the time of day (local time).
|
|
Set time of day. Sets the time of day (local time).
|
|
Set time of day. Sets the time of day (local time).
|
|
Set local time. Set the local date and time represented by this DateTime object.
|
|
Set local time. Set the local date and time represented by this DateTime object.
|
|
Set local time. Set the local date and time represented by this DateTime object.
|
|
Set local time. Set the local date and time represented by this DateTime object.
|
|
Set local time. Set the local date and time represented by this DateTime object.
|
|
Set local time. Set the local date and time represented by this DateTime object.
|
|
Set time. Set the date and time (UTC) represented by this DateTime object.
|
|
Set time. Set the date and time (UTC) represented by this DateTime object.
|
|
Set time. Set the date and time (UTC) represented by this DateTime object.
|
|
Set time. Set the date and time (UTC) represented by this DateTime object.
|
|
Set time. Set the date and time (UTC) represented by this DateTime object.
|
|
Set time. Set the date and time (UTC) represented by this DateTime object.
|
|
Set time zone. Sets the time zone of the local time by alias name. If no time zone of the specified alias name is found, UTC is assumed.
|
|
Set time zone. Sets the time zone of the local time to specified TimeZone object.
|
|
Shift DateTime. Shifts a DateTime by a specified amount of seconds. (This may be used for TimeZone transformations or DateTime arithmetic.)
|
|
Update broken down calendar time from ticks. Updates the broken down calendar time from the UTC ticks. An additional offset may be specified to calculate local time.
|
|
Update ticks from broken down calendar time.
|
|
Broken down time: Day of month (1...31).
|
|
Vector of default time zones.
|
|
Broken down time: DST flag.
|
|
Broken down time: Hour (0...23).
|
|
Leap month.
|
|
Time zone memory management flag.
|
|
Broken down time: Minute (0...59).
|
|
Broken down time: Month (1...12).
|
|
Initial value: { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
|
|
Initial value: { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
|
|
Initial value: { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335} ..11]) and leap years (NUM_DAYS[12...23]). |
|
Start tick count for POSIX epoch.
|
|
Reference ticks of a sunday.
|
|
Broken down time: Second (0...59).
|
|
Number of UTC seconds since 0001-01-01 00:00:00.
|
|
Leap year neutral tick step: 100 years.
|
|
Ticks per day.
|
|
Leap year neutral tick step: 1 year.
|
|
Leap year neutral tick step: 3 years.
|
|
Leap year neutral tick step: 400 years.
|
|
Leap year neutral tick step: 4 years.
|
|
Timestamp (string representation, "YYYY-MM-DD HH:MM:SS").
|
|
Timestamp date separator.
|
|
Timestamp datetime separator.
|
|
Timestamp time separator.
|
|
Local time zone.
|
|
Time zone: Egypt (UTC+02).
|
|
Time zone: Europe/Central (CET/CEST).
|
|
Time zone: Europe/Eastern (EET/EEST).
|
|
Time zone: Europe/Western (WET/WEST).
|
|
Time zone: GMT.
|
|
Time zone: Russia/Western (UTC+03).
|
|
Time zone: United Kingdom (WET/BST).
|
|
Time zone: USA/Alaska (AKST/AKDT).
|
|
Time zone: USA/Central (CST/CDT).
|
|
Time zone: USA/Eastern (EST/EDT).
|
|
Time zone: USA/Mountain (MST/MDT).
|
|
Time zone: USA/Pacific (PST/PDT).
|
|
Time zone: UTC.
|
|
Time zone: UTC-0100.
|
|
Time zone: UTC-0200.
|
|
Time zone: UTC-0300.
|
|
Time zone: UTC-0400.
|
|
Time zone: UTC-0500.
|
|
Time zone: UTC-0600.
|
|
Time zone: UTC-0700.
|
|
Time zone: UTC-0800.
|
|
Time zone: UTC-0900.
|
|
Time zone: UTC-1000.
|
|
Time zone: UTC-1100.
|
|
Time zone: UTC-1100.
|
|
Time zone: UTC+0100.
|
|
Time zone: UTC+0200.
|
|
Time zone: UTC+0300.
|
|
Time zone: UTC+0330.
|
|
Time zone: UTC+0400.
|
|
Time zone: UTC+0430.
|
|
Time zone: UTC+0500.
|
|
Time zone: UTC+0530.
|
|
Time zone: UTC+0545.
|
|
Time zone: UTC+0600.
|
|
Time zone: UTC+0630.
|
|
Time zone: UTC+0700.
|
|
Time zone: UTC+0800.
|
|
Time zone: UTC+0900.
|
|
Time zone: UTC+0930.
|
|
Time zone: UTC+1000.
|
|
Time zone: UTC+1100.
|
|
Time zone: UTC+1100.
|
|
Broken down time: UTC offset (minutes).
|
|
Broken down time: Day of week (0...6, where 0 = Sunday).
|
|
Initial value: { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
|
|
Initial value: { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}
|
|
Broken down time: Year.
|
|
Broken down time: Day of year (1...366).
|