libzypp 8.13.6
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | Friends

zypp::Date Class Reference

Store and operate on date (time_t). More...

#include <Date.h>

List of all members.

Public Types

enum  TimeBase { TB_LOCALTIME, TB_UTC }
typedef time_t ValueType

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.
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").
Arithmetic operations.

+ - * / are provided via conversion to time_t.

Dateoperator+= (const time_t rhs)
Dateoperator-= (const time_t rhs)
Dateoperator*= (const time_t rhs)
Dateoperator/= (const time_t rhs)
Dateoperator++ ()
Dateoperator-- ()
Date operator++ (int)
Date operator-- (int)

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

Private Attributes

ValueType _date
 Calendar time.

Friends

std::ostream & operator<< (std::ostream &str, const Date &obj)

Detailed Description

Store and operate on date (time_t).

Definition at line 31 of file Date.h.


Member Typedef Documentation

typedef time_t zypp::Date::ValueType

Definition at line 37 of file Date.h.


Member Enumeration Documentation

Enumerator:
TB_LOCALTIME 
TB_UTC 

Definition at line 52 of file Date.h.


Constructor & Destructor Documentation

zypp::Date::Date ( ) [inline]

Default ctor: 0.

Definition at line 55 of file Date.h.

zypp::Date::Date ( ValueType  date_r) [inline]

Ctor taking time_t value.

Definition at line 59 of file Date.h.

zypp::Date::Date ( const std::string &  seconds_r)

Ctor taking time_t value as string.

Definition at line 56 of file Date.cc.

References _date, and zypp::str::strtonum().

zypp::Date::Date ( const std::string &  date_str,
const std::string &  format 
)

Ctor from a date_str (in localtime) formatted using format.

Exceptions:
DateFormatExceptionin case date_str cannot be parsed according to format.

Definition at line 59 of file Date.cc.

zypp::Date::Date ( const std::string &  date_str,
const std::string &  format,
Date::TimeBase  base_r 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 63 of file Date.cc.

References _date, zypp::adjustLocale(), zypp::str::form(), zypp::restoreLocale(), and TB_UTC.


Member Function Documentation

static Date zypp::Date::now ( ) [inline, static]
zypp::Date::operator ValueType ( ) const [inline]

Conversion to time_t.

Definition at line 81 of file Date.h.

References _date.

Date& zypp::Date::operator+= ( const time_t  rhs) [inline]

Definition at line 88 of file Date.h.

References _date.

Date& zypp::Date::operator-= ( const time_t  rhs) [inline]

Definition at line 89 of file Date.h.

References _date.

Date& zypp::Date::operator*= ( const time_t  rhs) [inline]

Definition at line 90 of file Date.h.

References _date.

Date& zypp::Date::operator/= ( const time_t  rhs) [inline]

Definition at line 91 of file Date.h.

References _date.

Date& zypp::Date::operator++ ( ) [inline]

Definition at line 93 of file Date.h.

References _date.

Date& zypp::Date::operator-- ( ) [inline]

Definition at line 94 of file Date.h.

References _date.

Date zypp::Date::operator++ ( int  ) [inline]

Definition at line 96 of file Date.h.

References _date.

Date zypp::Date::operator-- ( int  ) [inline]

Definition at line 97 of file Date.h.

References _date.

std::string zypp::Date::form ( const std::string &  format_r) const [inline]

Return string representation according to format as localtime.

See also:
'man strftime' (which is used internaly) for valid conversion specifiers in format.
Returns:
An empty string on illegal format.

Definition at line 107 of file Date.h.

References form(), and TB_LOCALTIME.

Referenced by asSeconds(), asString(), zypp::HistoryItemRepoUrlChange::dumpTo(), form(), and zypp::target::rpm::RpmDb::processConfigFiles().

std::string zypp::Date::form ( const std::string &  format_r,
Date::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.

Definition at line 88 of file Date.cc.

References _date, zypp::adjustLocale(), zypp::restoreLocale(), and TB_UTC.

std::string zypp::Date::asString ( ) const [inline]

Default string representation of Date.

The preferred date and time representation for the current locale.

Definition at line 115 of file Date.h.

References form().

Referenced by zypp::PublicKey::Impl::expiresAsString().

std::string zypp::Date::asSeconds ( ) const [inline]

Convert to string representation of calendar time in numeric form (like "1029255142").

Definition at line 121 of file Date.h.

References form().

Referenced by zypp::syscontent::Writer::Impl::writeXml().


Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  str,
const Date obj 
) [friend]

Stream output

Definition at line 134 of file Date.h.


Member Data Documentation

const Date::ValueType zypp::Date::second = 1 [static]

Definition at line 39 of file Date.h.

const Date::ValueType zypp::Date::minute = 60 [static]

Definition at line 40 of file Date.h.

const Date::ValueType zypp::Date::hour = 3600 [static]

Definition at line 41 of file Date.h.

const Date::ValueType zypp::Date::day = 86400 [static]

Definition at line 42 of file Date.h.

Referenced by zypp::PublicKey::Impl::daysToLive().

const Date::ValueType zypp::Date::month28 = 2419200 [static]

Definition at line 43 of file Date.h.

const Date::ValueType zypp::Date::month29 = 2505600 [static]

Definition at line 44 of file Date.h.

const Date::ValueType zypp::Date::month30 = 2592000 [static]

Definition at line 45 of file Date.h.

const Date::ValueType zypp::Date::month31 = 2678400 [static]

Definition at line 46 of file Date.h.

Definition at line 47 of file Date.h.

const Date::ValueType zypp::Date::year365 = 31536000 [static]

Definition at line 48 of file Date.h.

const Date::ValueType zypp::Date::year366 = 31622400 [static]

Definition at line 49 of file Date.h.

Definition at line 50 of file Date.h.

Calendar time.

The number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).

Definition at line 129 of file Date.h.

Referenced by Date(), form(), operator ValueType(), operator*=(), operator++(), operator+=(), operator--(), operator-=(), and operator/=().


The documentation for this class was generated from the following files: