19#include <zypp-core/base/Exception.h>
20#include <zypp-core/base/EnumClass.h>
65 explicit Date(
const std::string & seconds_r );
73 Date(
const std::string & date_str,
const std::string & format );
75 Date(
const std::string & date_str,
const std::string & format,
TimeBase base_r );
79 { return ::time( 0 ); }
112 std::string
form(
const std::string & format_r )
const
115 std::string
form(
const std::string & format_r,
TimeBase base_r )
const;
121 {
return form(
"%c" ); }
127 {
return form(
"%s" ); }
133 struct EDateFormatDef {
enum Enum {
142 typedef base::EnumClass<EDateFormatDef>
DateFormat;
145 struct ETimeFormatDef {
enum Enum {
151 typedef base::EnumClass<ETimeFormatDef>
TimeFormat;
154 struct ETimeZoneFormatDef {
enum Enum {
169 {
return print( DateFormat::calendar, timeFormat_r, timeZoneFormat_r, base_r ); }
172 {
return print( dateFormat_r, TimeFormat::seconds, timeZoneFormat_r, base_r ); }
175 {
return print( dateFormat_r, timeFormat_r, TimeZoneFormat::name, base_r ); }
178 {
return print( DateFormat::calendar, TimeFormat::seconds, timeZoneFormat_r, base_r ); }
181 {
return print( DateFormat::calendar, timeFormat_r, TimeZoneFormat::name, base_r ); }
184 {
return print( dateFormat_r, TimeFormat::seconds, TimeZoneFormat::name, base_r ); }
187 {
return print( DateFormat::calendar, TimeFormat::seconds, TimeZoneFormat::name, base_r ); }
193 {
return print( dateFormat_r, TimeFormat::none, TimeZoneFormat::none, base_r ); }
196 {
return printDate( DateFormat::calendar, base_r ); }
202 {
return print( DateFormat::none, timeFormat_r, timeZoneFormat_r, base_r ); }
205 {
return printTime( TimeFormat::seconds, timeZoneFormat_r, base_r ); }
208 {
return printTime( timeFormat_r, TimeZoneFormat::name, base_r ); }
211 {
return printTime( TimeFormat::seconds, TimeZoneFormat::name, base_r ); }
221 {
return printISO( DateFormat::calendar, timeFormat_r, timeZoneFormat_r, base_r ); }
224 {
return printISO( dateFormat_r, TimeFormat::seconds, timeZoneFormat_r, base_r ); }
227 {
return printISO( dateFormat_r, timeFormat_r, TimeZoneFormat::name, base_r ); }
230 {
return printISO( DateFormat::calendar, TimeFormat::seconds, timeZoneFormat_r, base_r ); }
233 {
return printISO( DateFormat::calendar, timeFormat_r, TimeZoneFormat::name, base_r ); }
236 {
return printISO( dateFormat_r, TimeFormat::seconds, TimeZoneFormat::name, base_r ); }
239 {
return printISO( DateFormat::calendar, TimeFormat::seconds, TimeZoneFormat::name, base_r ); }
252 inline std::ostream &
operator<<( std::ostream &
str,
const Date & obj )
253 {
return str << obj.asString(); }
258 std::ostream &
dumpAsXmlOn( std::ostream &
str,
const Date & obj,
const std::string & name_r =
"date" );
261 class DateFormatException :
public Exception
ValueType _date
Calendar time.
Date & operator+=(const time_t rhs)
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,...
static const ValueType year365
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'
static const ValueType hour
Date & operator*=(const time_t rhs)
static const ValueType day
Date operator+(const time_t rhs) const
static const ValueType month31
base::EnumClass< ETimeFormatDef > TimeFormat
'enum class TimeFormat'
static const ValueType minute
base::EnumClass< EDateFormatDef > DateFormat
'enum class DateFormat'
Date operator/(const time_t rhs) const
base::EnumClass< ETimeZoneFormatDef > TimeZoneFormat
'enum class TimeZoneFormat'
static const ValueType month30
static const ValueType month
Date operator-(const time_t rhs) const
Date & operator-=(const time_t rhs)
static const ValueType year366
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_LO...
std::string asString() const
Default string representation of Date.
std::string form(const std::string &format_r) const
Return string representation according to format as localtime.
static const ValueType month28
static const ValueType month29
std::string asSeconds() const
Convert to string representation of calendar time in numeric form (like "1029255142").
Date & operator/=(const time_t rhs)
static const ValueType second
friend std::ostream & operator<<(std::ostream &str, const Date &obj)
static Date now()
Return the current time.
Date operator*(const time_t rhs) const
static const ValueType year
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_LOCA...
const std::string & msg() const
Return the message string provided to the ctor.
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
std::ostream & dumpAsXmlOn(std::ostream &str, const Repository &obj)