Class representing a gregorian-date and time-of-day combination. The time component has microsecond resolution.
More...
|
| date_time (uint32_t yyyymmdd=date_time::undefined) |
| Constructor. By default, self will be in an 'undefined' state. Passing date_time::now_local or date_time::now_utc as constructor argument initializes self to the current system time. Otherwise ny other number in yyyymmdd format is acceptable as constructor argument. More...
|
|
| date_time (const date_time &other) |
| Copy constructor.
|
|
| date_time (const std::chrono::time_point< std::chrono::system_clock > &time_point) |
| Constructor. Translates given time_point as local-time.
|
|
| date_time (const char *date_time_str) |
| Constructor. Initializes self with given date_time_str by automatically interpreting its format. More...
|
|
| date_time (const date &date) |
| Constructs self from date. Time-of-day is set to midnight / start of day.
|
|
| date_time (uint32_t year, uint32_t month, uint32_t day) |
| Constructor. Time-of-day is set to midnight.
|
|
| date_time (const date &date, uint32_t hour, uint32_t minute, uint32_t second=0) |
| Constructor.
|
|
| date_time (uint32_t year, uint32_t month, uint32_t day, uint32_t hour, uint32_t minute, uint32_t second=0, uint32_t microseconds=0) |
| Constructor. Hour: 0-23, minute:0-59, second: 0-59, microseconds: 0-999999.
|
|
| date_time (const date &date, uint32_t hour, uint32_t minute, uint32_t second, uint32_t microseconds) |
| Constructor. Hour: 0-23, minute:0-59, second: 0-59, microseconds: 0-999999.
|
|
| date_time (const variant &variant) |
| Constructs self from given variant. More...
|
|
time_t | as_system_time (local_or_utc_time_select local_or_utc=tsa::local_time) const |
| Returns the time_t equivalent of self. More...
|
|
std::chrono::system_clock::time_point | as_time_point (local_or_utc_time_select local_or_utc) |
| Returns self as a std::chrono time_point. The given flag determines wheter self is interpreted as 'local' or 'UTC' time. More...
|
|
void | assign (const tsa::date_time &other, bool error_on_nil=true) |
| Assignment. More...
|
|
void | clear (void) |
| Resets the object to an 'undefined' state (see defined()).
|
|
date_time | convert_to_utc (void) const |
| Converts into 'universal time coordinate' time (ZULU time).
|
|
void | decr_microsec (int64_t n=1) |
| Decrements self by n microseconds. If the start of day is reached, the date is decremented.
|
|
bool | defined (void) const |
| Returns true if self has been initialized with a valid date-time. The default constructor does not initialize the object. More...
|
|
bool | has_time_zone_offset (void) const |
| Returns true if a timezone offset was defined.
|
|
uint32_t | hhmm (void) const |
| Returns the time-of-day as an hhmm integer.
|
|
uint32_t | hhmmss (void) const |
| Returns the time-of-day as an hhmmss integer.
|
|
uint32_t | hhmmssmmm (void) const |
| Returns the time-of-day as an hhmmssmmm integer.
|
|
uint64_t | hhmmssmmmmmm (void) const |
| Returns the time-of-day as an hhmmssmmmmmm integer.
|
|
uint32_t | hour (void) const |
| Returns the hour (0-23).
|
|
void | incr_date (int num_days=1) |
| Increments the date by num_days.
|
|
void | incr_microsec (int64_t n=1) |
| Increments self by n microseconds. If the end of day is reached, the date is incremented.
|
|
bool | is_midnight (void) const |
| Returns true if the time component (number of microseconds since midnight as returned by microsec_of_day() ) is zero.
|
|
uint32_t | microsec (void) const |
| Returns the microsecond (0-999999).
|
|
int64_t | microsec_since_midnight (void) const |
| Gets the time-of-day as the number of microseconds since midnight.
|
|
void | microsec_since_midnight (int64_t) |
| Sets the time-of-day in the form of the number of microseconds since midnight.
|
|
uint32_t | minute (void) const |
| Returns the minute (0-59).
|
|
bool | operator!= (const date_time &other) const |
| Returns true if self and other are not equal.
|
|
void | operator+= (const duration &duration) |
| Adds duration to self.
|
|
void | operator-= (const duration &duration) |
| Subtracts duration from self.
|
|
bool | operator< (const date_time &other) const |
| Returns true if self is smaller (earlier) than other.
|
|
bool | operator<= (const date_time &other) const |
| Returns true if self is smaller (earlier) or equal than other.
|
|
date_time & | operator= (const tsa::date_time &) |
| Assignment operator.
|
|
bool | operator== (const date_time &other) const |
| Returns true if self and other are equal.
|
|
bool | operator> (const date_time &other) const |
| Returns true if self is larger (later) than other.
|
|
bool | operator>= (const date_time &other) const |
| Returns true if self is larger (later) or equal than other.
|
|
uint32_t | second (void) const |
| Returns the second (0-59).
|
|
void | set (const std::chrono::system_clock::time_point &time_pt, local_or_utc_time_select local_or_utc=tsa::local_time) |
| Sets self to std::chrono::system_clock::time_point. More...
|
|
void | set_date (uint32_t year, uint32_t month, uint32_t day) |
| Sets the date. Time-of-day remains unchanged.
|
|
void | set_date (const date &) |
| Sets the date. Time-of-day remains unchanged.
|
|
void | set_date_from_string (const std::string &date_string, const char *date_format) |
| Sets the date from given date_string and format. See date::set_from_string() for valid format strings. This member is the equivalent of date::set_from_string(). More...
|
|
void | set_from_iso_string (const std::string &date_time_string) |
| Sets the date-time from a string in ISO format (yyyy-mm-ddThh:mm:ss:f). This member is very fast. More...
|
|
void | set_from_string (const std::string &date_time_string, const char *date_format=nullptr, char sep= 'T') |
| Sets self from given date_time_string. The given date-time separator character must be either 'T' and ' '. If date_format is given as a nullptr then the function will try to automatically recognize the date format. This process is much slower than when passing the correct date format. See date::from_string(). More...
|
|
void | set_hhmm (uint32_t hhmm) |
| Sets the time - of - day from an integer.
|
|
void | set_hhmmss (uint32_t hhmmss) |
| Sets the time-of-day from an integer.
|
|
void | set_time (uint32_t hour, uint32_t minute, uint32_t second, uint32_t microsecond) |
| Sets the time-of-day to given hour, minute, second, and microsecond.
|
|
void | set_time (uint32_t hour, uint32_t minute, uint32_t second) |
| Sets the time-of-day to given hour, minute, second.
|
|
void | set_time (uint32_t hour, uint32_t minute) |
| Sets the time-of-day to the given hour, minute.
|
|
void | set_time_from_string (const std::string &time_string) |
| Sets the time-of-day from given time_string. More...
|
|
void | set_time_t (time_t system_time, local_or_utc_time_select local_or_utc, set_timezone_offset_select tz=no_timezone_offset) |
| Sets self to given system_time. More...
|
|
void | set_to_now (local_or_utc_time_select local_or_utc_flag, set_timezone_offset_select set_tz_offset_flag=no_timezone_offset) |
| Sets self to the operating system's current date-time. More...
|
|
int | timezone_half_hour_offset (void) const |
| Returns the timezone offset as a number of 30 minute intervals.
|
|
void | timezone_half_hour_offset (int) |
| Sets the timezone offset as a number of 30 minute intervals.
|
|
double | timezone_offset (void) const |
| Returns the timezone offset in hours (which can be a fraction).
|
|
void | timezone_offset (double hours) |
| Sets the timezone offset as a number of hours (which can be a fraction)
|
|
std::string | to_string (const char *date_format, const char *time_format, char sep) const |
| Returns date and time as a formated string. More...
|
|
std::string | to_string (char sep= 'T') const |
| Returns a ISO date-time string (yyyy-mm-ddThh:mm:ss:f) with given separator ('T' by default). This member function is much faster than the more flexible function taking format string arguments. More...
|
|
std::string | to_time_string (const char *format="hh:mm:ss.f") const |
| Returns time-of-day as a formated string. More...
|
|
uint32_t | usec (void) const |
| Returns the microsecond (0-999999).
|
|
void | verify_defined (void) const |
| Throws an exceptio if self is not defined. See defined() member.
|
|
| date (const date &other) |
| Copy constructor.
|
|
| date (const char *date_str) |
| Constructor. Requires unambiguous date string (e.g. yyyy-mm-dd, yyyy/mm/dd, yyyy.mm.dd)
|
|
| date (const variant &variant) |
| Constructor. May throw exception if variant cannot be converted to a date.
|
|
| date (uint32_t yyyymmdd=date::undefined) |
| Constructor. By default, self is not initialized; defined() will return false. Use the date::now argument to initialize to the current system date. Otherwise initialize to any other date by submitting a valid yyyymmdd argument. More...
|
|
| date (int year, int month, int day) |
| Constructor taking year, month, and day arguments.
|
|
void | assign (const date &, bool _error_on_undefined=true) |
| Assigns a given date to self. Throws an exception if given date is not defined (see defined()) and _error_on_undefined flag is true.
|
|
void | clear (void) |
| Sets self to an 'undefined' state, where defined() will return false.
|
|
int | day_of_month (void) const |
| Returns the day of the month (1-31).
|
|
week_day | day_of_week (void) const |
| Returns the day of the week (Sunday = 0, Saturday = 6).
|
|
int | day_of_year (void) const |
| Returns the day of the year (1-366).
|
|
void | decr (int num_days) |
| Decrements self by num_days.
|
|
void | decr_to_prev_weekday (void) |
| Decrements self to previous weekday, skipping sundays or saturdays.
|
|
bool | defined (void) const |
| Returns true if self is not 'null'; in other words, the date was defined.
|
|
bool | in_leap_year (void) const |
| Returns true if the date's year is a leap year.
|
|
void | incr (int num_days) |
| Increments self by num_days.
|
|
void | incr_to_next_weekday (void) |
| Increments self to next weekday, skipping sundays and saturdays.
|
|
bool | is_weekend (void) const |
| Returns true if current day of week is either Saturday or Sunday.
|
|
void | julian_day (int julian_day) |
| Resets the internal julian-day value.
|
|
int | julian_day (void) const |
| Returns the julian-day.
|
|
int | month (void) const |
| Returns the month (1-12).
|
|
bool | operator!= (const date &other) const |
| Returns true if self is not equal to other.
|
|
void | operator+= (const duration &num_days) |
| Adds a given number of days to self. The given duration must not have an intraday component.
|
|
void | operator-= (const duration &num_days) |
| Subtracts a given number of days from self. The given duration must not have an intraday component.
|
|
bool | operator< (const date &other) const |
| Returns true if self is smaller than other.
|
|
bool | operator<= (const date &other) const |
| Returns true if self is smaller or equal to other.
|
|
date & | operator= (const date &other) |
| Assignment operator.
|
|
bool | operator== (const date &other) const |
| Returns true if self is equal to other.
|
|
bool | operator> (const date &other) const |
| Returns true if self is larger than other.
|
|
bool | operator>= (const date &other) const |
| Returns true if self is larger or equal to other.
|
|
void | set (uint32_t year, uint32_t month, uint32_t day) |
| Sets self to given year, month, day combination.
|
|
void | set_from_iso_string (const std::string &iso_date_string) |
| Sets the date from the given ISO date string with format: "yyyy-mm-dd". This member function is much faster then the one declaring a format parameter. More...
|
|
void | set_from_string (const std::string &date_string, const char *format_string="") |
| Sets the date from the given date_string interpreted according to given format_string. More...
|
|
void | set_to_now (tsa::local_or_utc_time_select lu) |
| Sets self to the operating system's current date.
|
|
std::string | to_string (const char *format) const |
| Returns the date as a string formated according to given format. More...
|
|
std::string | to_string (void) const |
| Returns the date as an ISO date string (yyyy-mm-dd).
|
|
int | year (void) const |
| Returns the year.
|
|
void | yyyymmdd (uint32_t yyyymmdd) |
| Sets the date from an integer in yyyymmdd format such as 19990403 (representing April 3 1999).
|
|
uint32_t | yyyymmdd (void) const |
| Returns the current date as a number.
|
|