+++ /dev/null
-/*---------------------------------------------------------------------\
-| |
-| __ __ ____ _____ ____ |
-| \ \ / /_ _/ ___|_ _|___ \ |
-| \ V / _` \___ \ | | __) | |
-| | | (_| |___) || | / __/ |
-| |_|\__,_|____/ |_| |_____| |
-| |
-| core system |
-| (C) SuSE GmbH |
-\----------------------------------------------------------------------/
-
- File: Date.cc
-
- Author: Michael Andres <ma@suse.de>
- Maintainer: Michael Andres <ma@suse.de>
-
- Purpose: Store and operate on date (time_t).
-
-/-*/
-
-// for strptime
-// #define _XOPEN_SOURCE
-
-#include <iostream>
-
-#include <y2util/stringutil.h>
-#include <y2util/Date.h>
-
-using namespace std;
-
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : Date::form
-// METHOD TYPE : std::string
-//
-// DESCRIPTION :
-//
-std::string Date::form( const std::string & format, time_t tval_r )
-{
- static char buf[1024];
- if ( !strftime( buf, 1024, format.c_str(), localtime( &tval_r ) ) )
- return string();
- return buf;
-}
-
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : Date::fromSECONDS
-// METHOD TYPE : time_t
-//
-// DESCRIPTION :
-//
-time_t Date::fromSECONDS( const std::string & str_r )
-{
- return atol( str_r.c_str() );
-}
-
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : Date::toSECONDS
-// METHOD TYPE : std::string
-//
-// DESCRIPTION :
-//
-std::string Date::toSECONDS( time_t tval_r )
-{
- return form( "%s", tval_r );
-}
-
-#if 0
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : Date::scan
-// METHOD TYPE : time_t
-//
-// DESCRIPTION :
-//
-time_t Date::scan( const std::string & format, const std::string & str_r )
-{
- struct tm tm;
- if ( strptime( str_r.c_str(), format.c_str(), &tm ) == NULL )
- return 0;
- DBG << "---------->" << asctime( &tm ) << endl;
- return mktime( &tm );
-}
-#endif
-
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : Date::asString
-// METHOD TYPE : std::string
-//
-// DESCRIPTION :
-//
-std::string Date::asString() const
-{
- return form( "%c", _date );
-}
-
-/******************************************************************
-**
-**
-** FUNCTION NAME : operator<<
-** FUNCTION TYPE : std::ostream &
-**
-** DESCRIPTION :
-*/
-std::ostream & operator<<( std::ostream & str, const Date & obj )
-{
- return str << obj.asString();
-}
-
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| |
-| __ __ ____ _____ ____ |
-| \ \ / /_ _/ ___|_ _|___ \ |
-| \ V / _` \___ \ | | __) | |
-| | | (_| |___) || | / __/ |
-| |_|\__,_|____/ |_| |_____| |
-| |
-| core system |
-| (C) SuSE GmbH |
-\----------------------------------------------------------------------/
-
- File: Date.h
-
- Author: Michael Andres <ma@suse.de>
- Maintainer: Michael Andres <ma@suse.de>
-
- Purpose: Store and operate on date (time_t).
-
-/-*/
-#ifndef _Date_h_
-#define _Date_h_
-
-#include <ctime>
-#include <iosfwd>
-#include <string>
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : Date
-//
-/**
- * @short Store and operate on date (time_t).
- **/
-class Date {
-
- private:
-
- /**
- * Calendar time. The number of seconds elapsed since
- * 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).
- **/
- time_t _date;
-
- public:
-
- // static constructors and conversion
-
- /**
- * Return the current time.
- **/
- static time_t now() { return time( 0 ); }
-
- /**
- * Return string representation of date according to format.
- * See 'man strftime' (which is used internaly) for valid
- * conversion specifiers in format.
- *
- * Retruns an empty string on illegal format.
- **/
- static std::string form( const std::string & format, time_t tval_r );
-
- /**
- * Convert from string representation of calendar time in
- * numeric form (like "1029255142").
- **/
- static time_t fromSECONDS( const std::string & str_r );
-
- /**
- * Convert to string representation of calendar time in
- * numeric form (like "1029255142").
- **/
- static std::string toSECONDS( time_t tval_r );
-
- public:
-
- /**
- * Constructor
- **/
- Date( time_t date_r = 0 ) : _date( date_r ) {}
- Date( const std::string & seconds_r ) : _date( fromSECONDS (seconds_r) ) {}
-
- /**
- * Conversion to time_t
- **/
- operator time_t() const { return _date; }
-
- Date & operator+=( const time_t rhs ) { _date += rhs; return *this; }
- Date & operator-=( const time_t rhs ) { _date -= rhs; return *this; }
- Date & operator*=( const time_t rhs ) { _date *= rhs; return *this; }
- Date & operator/=( const time_t rhs ) { _date /= rhs; return *this; }
-
- Date & operator++(/*prefix*/) { _date += 1; return *this; }
- Date & operator--(/*prefix*/) { _date -= 1; return *this; }
-
- Date operator++(int/*postfix*/) { return _date++; }
- Date operator--(int/*postfix*/) { return _date--; }
-
- /**
- * Member version of 'static form'.
- **/
- std::string form( const std::string & format ) const { return form( format, _date ); }
-
- /**
- * Default string representation of Date. The preferred
- * date and time representation for the current locale.
- **/
- std::string asString() const;
-
- /**
- * Write asString.
- **/
- friend std::ostream & operator<<( std::ostream & str, const Date & obj );
-};
-
-///////////////////////////////////////////////////////////////////
-
-#endif // _Date_h_
#include <string>
#include <list>
-#include "zypp/NeedAType.h"
+
+#include "zypp/Date.h"
///////////////////////////////////////////////////////////////////
namespace zypp
{
public:
/** Default ctor */
- ChangelogEntry( const Date & d,
- const std::string & a,
+ ChangelogEntry( const Date & d,
+ const std::string & a,
const std::string & t )
: _date( d ), _author( a ), _text( t )
{};
std::string _text;
};
+ /** List of ChangelogEntry. */
typedef std::list<ChangelogEntry> Changelog;
/** \relates ChangelogEntry */
std::ostream & operator<<( std::ostream & out, const ChangelogEntry & obj );
-
+
///////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/Date.cc
+ *
+*/
+#include <iostream>
+//#include "zypp/base/Logger.h"
+
+#include "zypp/Date.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : Date::form
+ // METHOD TYPE : std::string
+ //
+ std::string Date::form( const std::string & format_r ) const
+ {
+ static char buf[1024];
+ if ( ! strftime( buf, 1024, format_r.c_str(), localtime( &_date ) ) )
+ return std::string();
+ return buf;
+ }
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/Date.h
+ *
+*/
+#ifndef ZYPP_DATE_H
+#define ZYPP_DATE_H
+
+#include <ctime>
+#include <iosfwd>
+#include <string>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : Date
+ //
+ /** Store and operate on date (time_t).
+ */
+ class Date
+ {
+ friend std::ostream & operator<<( std::ostream & str, const Date & obj );
+
+ public:
+
+ /** Default ctor: 0 */
+ Date()
+ : _date( 0 )
+ {}
+ /** Ctor taking time_t value. */
+ Date( time_t date_r )
+ : _date( date_r )
+ {}
+ //Date( const std::string & seconds_r ) : _date( fromSECONDS (seconds_r) ) {}
+
+ /** Return the current time. */
+ static time_t now()
+ { return ::time( 0 ); }
+
+ public:
+ /** Conversion to time_t. */
+ operator time_t() const
+ { return _date; }
+
+ /** \name Arithmetic operations.
+ * \c + \c - \c * \c / are provided via conversion to time_t.
+ */
+ //@{
+ Date & operator+=( const time_t rhs ) { _date += rhs; return *this; }
+ Date & operator-=( const time_t rhs ) { _date -= rhs; return *this; }
+ Date & operator*=( const time_t rhs ) { _date *= rhs; return *this; }
+ Date & operator/=( const time_t rhs ) { _date /= rhs; return *this; }
+
+ Date & operator++(/*prefix*/) { _date += 1; return *this; }
+ Date & operator--(/*prefix*/) { _date -= 1; return *this; }
+
+ Date operator++(int/*postfix*/) { return _date++; }
+ Date operator--(int/*postfix*/) { return _date--; }
+ //@}
+
+ public:
+ /** Return string representation according to format.
+ * \see 'man strftime' (which is used internaly) for valid
+ * conversion specifiers in format.
+ *
+ * \return An empty string on illegal format.
+ **/
+ std::string form( const std::string & format_r ) const;
+
+ /** Default string representation of Date.
+ * The preferred date and time representation for the current locale.
+ **/
+ std::string asString() const
+ { return form( "%c" ); }
+
+ /** Convert to string representation of calendar time in
+ * numeric form (like "1029255142").
+ **/
+ std::string asSeconds() const
+ { return form( "%s" ); }
+
+ private:
+ /** Calendar time.
+ * The number of seconds elapsed since 00:00:00 on January 1, 1970,
+ * Coordinated Universal Time (UTC).
+ **/
+ time_t _date;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates Date Stream output */
+ inline std::ostream & operator<<( std::ostream & str, const Date & obj )
+ { return str << obj.asString(); }
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_DATE_H
Capability.h \
CapFactory.h \
CapSet.h \
+ Date.h \
Dependencies.h \
Edition.h \
Rel.h \
Capability.cc \
CapFactory.cc \
CapSet.cc \
+ Date.cc \
Dependencies.cc \
Edition.cc \
Rel.cc \
//@{
- /** Class representing an URL.
- something like liby2utils Url class. But we
- need clearly documented rules for parsing, and the way the broken down
- URL parts are stored withtin the class. This addresses especially
- the escaping and deescaping of special characters. It must be obvious to
- the user of the class, wheter an interface funtion deals with
- escaped, deescaped or hidden (in case of password) representation of the
- value.
-
- These rule may depend on the kind of URL protocol. The same for the
- recognized set of URL options we support. User/Passwd can be given
- in the URL or as option.
-
- There could be a common URL interface class which forwards all requests
- to an implementation class which may be specialized dependent on the URL
- protocol.
-
- There should be no obvious difference between known and unknown protocols.
- It should be possible to register an implementation class factory (or
- prototype) for a certain protocol at runtime.
- */
- typedef std::string Url;
-
/** Single line of (human readable) text.
probabely sufficient as typedef. we may use it to classify the
various strings and string lists within resolvable and other classes.
/** Candidate for string unification? */
typedef std::list<std::string> PackageKeywords;
- /** Class representing a Date (time_t). Basically store a time_t and offer
- conversions into formated strings. */
- typedef time_t Date;
-
/** Vendor. Worth a typedef. Maybe a class unifying the strings. */
typedef std::string Vendor;
#include "zypp/detail/ResObjectFactory.h"
#include "zypp/ByteCount.h"
+#include "zypp/Date.h"
#include "zypp/NeedAType.h" // volatile include propagating type drafts