libzypp 17.31.23
|
Store and operate on date (time_t). More...
#include <Date.h>
Classes | |
struct | EDateFormatDef |
Date formats for printing (use like 'enum class DateFormat') More... | |
struct | ETimeFormatDef |
Time formats for printing (use like 'enum class TimeFormat') More... | |
struct | ETimeZoneFormatDef |
Timezone indicator for printing (use like 'enum class TimeZoneFormat') More... | |
Public Types | |
typedef time_t | ValueType |
typedef time_t | Duration |
Public Member Functions | |
Date () | |
Default ctor: 0. | |
Date (ValueType date_r) | |
Ctor taking time_t value. | |
Date (const std::string &seconds_r) | |
Ctor taking time_t value as string. | |
Date (const std::string &date_str, const std::string &format) | |
Ctor from a date_str (in localtime) formatted using format. | |
Date (const std::string &date_str, const std::string &format, TimeBase base_r) | |
operator ValueType () const | |
Conversion to time_t. | |
Static Public Member Functions | |
static Date | now () |
Return the current time. | |
Static Public Attributes | |
static const ValueType | second = 1 |
static const ValueType | minute = 60 |
static const ValueType | hour = 3600 |
static const ValueType | day = 86400 |
static const ValueType | month28 = 2419200 |
static const ValueType | month29 = 2505600 |
static const ValueType | month30 = 2592000 |
static const ValueType | month31 = 2678400 |
static const ValueType | month = month30 |
static const ValueType | year365 = 31536000 |
static const ValueType | year366 = 31622400 |
static const ValueType | year = year365 |
Friends | |
std::ostream & | operator<< (std::ostream &str, const Date &obj) |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &str, const Date &obj) |
Stream output. | |
std::ostream & | dumpAsXmlOn (std::ostream &str, const Date &obj, const std::string &name_r="date") |
XML output. | |
Arithmetic operations. | |
enum | TimeBase { TB_LOCALTIME , TB_UTC } |
Date | operator+ (const time_t rhs) const |
Date | operator- (const time_t rhs) const |
Date | operator* (const time_t rhs) const |
Date | operator/ (const time_t rhs) const |
Date & | operator+= (const time_t rhs) |
Date & | operator-= (const time_t rhs) |
Date & | operator*= (const time_t rhs) |
Date & | operator/= (const time_t rhs) |
Date & | operator++ () |
Date & | operator-- () |
Date | operator++ (int) |
Date | operator-- (int) |
std::string | form (const std::string &format_r) const |
Return string representation according to format as localtime. | |
std::string | form (const std::string &format_r, TimeBase base_r) const |
std::string | asString () const |
Default string representation of Date. | |
std::string | asSeconds () const |
Convert to string representation of calendar time in numeric form (like "1029255142"). | |
Printing in various predefined formats | |
typedef base::EnumClass< EDateFormatDef > | DateFormat |
'enum class DateFormat' | |
typedef base::EnumClass< ETimeFormatDef > | TimeFormat |
'enum class TimeFormat' | |
typedef base::EnumClass< ETimeZoneFormatDef > | TimeZoneFormat |
'enum class TimeZoneFormat' | |
ValueType | _date |
Calendar time. | |
std::string | print (DateFormat dateFormat_r=DateFormat::calendar, TimeFormat timeFormat_r=TimeFormat::seconds, TimeZoneFormat timeZoneFormat_r=TimeZoneFormat::name, TimeBase base_r=TB_LOCALTIME) const |
Default format is '2014-02-07 07:06:41 CET' The default is DateFormat::calendar, TimeFormat::seconds, TimeZoneFormat::name and TB_LOCALTIME. | |
std::string | print (TimeFormat timeFormat_r, TimeZoneFormat timeZoneFormat_r=TimeZoneFormat::name, TimeBase base_r=TB_LOCALTIME) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | print (DateFormat dateFormat_r, TimeZoneFormat timeZoneFormat_r, TimeBase base_r=TB_LOCALTIME) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | print (DateFormat dateFormat_r, TimeFormat timeFormat_r, TimeBase base_r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | print (TimeZoneFormat timeZoneFormat_r, TimeBase base_r=TB_LOCALTIME) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | print (TimeFormat timeFormat_r, TimeBase base_r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | print (DateFormat dateFormat_r, TimeBase base_r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | print (TimeBase base_r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | printDate (DateFormat dateFormat_r=DateFormat::calendar, TimeBase base_r=TB_LOCALTIME) const |
Convenience for printing the date only ['2014-02-07' ] The default is DateFormat::calendar and TB_LOCALTIME. | |
std::string | printDate (TimeBase base_r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | printTime (TimeFormat timeFormat_r=TimeFormat::seconds, TimeZoneFormat timeZoneFormat_r=TimeZoneFormat::name, TimeBase base_r=TB_LOCALTIME) const |
Convenience for printing the time only ['07:06:41 CET' ] The default is DateFormat::calendar and TB_LOCALTIME. | |
std::string | printTime (TimeZoneFormat timeZoneFormat_r, TimeBase base_r=TB_LOCALTIME) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | printTime (TimeFormat timeFormat_r, TimeBase base_r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | printTime (TimeBase base_r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | printISO (DateFormat dateFormat_r=DateFormat::calendar, TimeFormat timeFormat_r=TimeFormat::seconds, TimeZoneFormat timeZoneFormat_r=TimeZoneFormat::name, TimeBase base_r=TB_LOCALTIME) const |
Default ISO 8601 format is '2014-02-07T07:06:41+01' | |
std::string | printISO (TimeFormat timeFormat_r, TimeZoneFormat timeZoneFormat_r=TimeZoneFormat::name, TimeBase base_r=TB_LOCALTIME) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | printISO (DateFormat dateFormat_r, TimeZoneFormat timeZoneFormat_r, TimeBase base_r=TB_LOCALTIME) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | printISO (DateFormat dateFormat_r, TimeFormat timeFormat_r, TimeBase base_r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | printISO (TimeZoneFormat timeZoneFormat_r, TimeBase base_r=TB_LOCALTIME) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | printISO (TimeFormat timeFormat_r, TimeBase base_r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | printISO (DateFormat dateFormat_r, TimeBase base_r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
std::string | printISO (TimeBase base_r) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
typedef time_t zypp::Date::ValueType |
typedef time_t zypp::Date::Duration |
typedef base::EnumClass<EDateFormatDef> zypp::Date::DateFormat |
typedef base::EnumClass<ETimeFormatDef> zypp::Date::TimeFormat |
typedef base::EnumClass<ETimeZoneFormatDef> zypp::Date::TimeZoneFormat |
enum with explicitly given ref zypp::Date::TimeBase |
|
inline |
|
explicit |
zypp::Date::Date | ( | const std::string & | date_str, |
const std::string & | format | ||
) |
Ctor from a date_str (in localtime) formatted using format.
DateFormatException | in case date_str cannot be parsed according to format. |
zypp::Date::Date | ( | const std::string & | date_str, |
const std::string & | format, | ||
Date::TimeBase | base_r | ||
) |
|
inlinestatic |
|
inline |
|
inline |
std::string zypp::Date::form | ( | const std::string & | format_r, |
Date::TimeBase | base_r | ||
) | const |
|
inline |
|
inline |
std::string zypp::Date::print | ( | DateFormat | dateFormat_r = DateFormat::calendar , |
TimeFormat | timeFormat_r = TimeFormat::seconds , |
||
TimeZoneFormat | timeZoneFormat_r = TimeZoneFormat::name , |
||
TimeBase | base_r = TB_LOCALTIME |
||
) | const |
Default format is '2014-02-07 07:06:41 CET'
The default is DateFormat::calendar, TimeFormat::seconds, TimeZoneFormat::name and TB_LOCALTIME.
For other formats you don't have to repeat all the defaults, just pass the values where you differ.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Convenience for printing the date only ['2014-02-07'
] The default is DateFormat::calendar and TB_LOCALTIME.
|
inline |
|
inline |
Convenience for printing the time only ['07:06:41 CET'
] The default is DateFormat::calendar and TB_LOCALTIME.
|
inline |
|
inline |
|
inline |
std::string zypp::Date::printISO | ( | DateFormat | dateFormat_r = DateFormat::calendar , |
TimeFormat | timeFormat_r = TimeFormat::seconds , |
||
TimeZoneFormat | timeZoneFormat_r = TimeZoneFormat::name , |
||
TimeBase | base_r = TB_LOCALTIME |
||
) | const |
Default ISO 8601 format is '2014-02-07T07:06:41+01'
'Z'
to indicate UTC (Zulu time) rather than printing '+00'
.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
friend |
|
related |
|
related |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
private |