36        const char * tmp = ::setlocale( LC_TIME, NULL );
 
   37        _mylocale = tmp ? tmp : 
"";
 
   39        if ( _mylocale.find( 
"UTF-8" ) == std::string::npos
 
   40          && _mylocale.find( 
"utf-8" ) == std::string::npos
 
   41          && _mylocale != 
"POSIX" 
   47          std::string needLocale = 
".UTF-8";
 
   48          std::string::size_type loc = _mylocale.find_first_of( 
".@" );
 
   49          if ( loc != std::string::npos )
 
   52            needLocale = _mylocale.substr( 0, loc ) + needLocale;
 
   53            loc = _mylocale.find_last_of( 
'@' );
 
   54            if ( loc != std::string::npos )
 
   57              needLocale += _mylocale.substr( loc );
 
   63            needLocale = _mylocale + needLocale;
 
   65          ::setlocale( LC_TIME, needLocale.c_str() );
 
   80        if ( ! _mylocale.empty() )
 
   81          ::setlocale( LC_TIME, _mylocale.c_str() );
 
   85      std::string _mylocale;
 
   89    inline bool isDST( 
struct tm & tm )
 
   91      time_t t = ::mktime( &tm );
 
   92      struct tm *tm2 = ::localtime( &t );
 
   93      return ( tm2 && tm2->tm_isdst > 0 );
 
   98      static const char * fmt[] = {
 
  107      return fmt[dateFormat_r.asIntegral()];
 
  112      static const char * fmt[] = {
 
  118      return fmt[timeFormat_r.asIntegral()];
 
  123      static const char * fmt[] = {
 
  128      return fmt[timeZoneFormat_r.asIntegral()];
 
  137      static char buf[512];
 
  138      if ( ! strftime( buf, 512, format_r.c_str(), (base_r == 
Date::TB_UTC ? gmtime : localtime)( &date_r ) ) )
 
  143        unsigned l = ::strlen( buf );
 
  145          && ( buf[l-1] == 
'0' )
 
  146          && ( buf[l-2] == 
'0' )
 
  147          && ( buf[l-5] == 
'+' || buf[l-5] == 
'-') )
 
  171  Date::Date( 
const std::string & date_str, 
const std::string & format )
 
 
  180    struct tm tm = {0,0,0,0,0,0,0,0,0,0,0};
 
  181    char * res = ::strptime( date_str.c_str(), format.c_str(), &tm );
 
  187    _date = (base_r == 
TB_UTC ? ::timegm : ::timelocal)( &tm );
 
 
  191  { 
return doForm( format_r, base_r, 
_date ); }
 
 
  196    if ( dateFormat_r != DateFormat::none )
 
  197      str << _dateFormat( dateFormat_r );
 
  198    if ( timeFormat_r != TimeFormat::none )
 
  200      if ( dateFormat_r != DateFormat::none )
 
  202      str << _timeFormat( timeFormat_r );
 
  203      if ( timeZoneFormat_r != TimeZoneFormat::none )
 
  204        str << _timeZoneFormat( timeZoneFormat_r );
 
  206    return doForm( 
str, base_r, 
_date );
 
 
  212    if ( dateFormat_r != DateFormat::none )
 
  213      str << _dateFormat( dateFormat_r );
 
  214    if ( timeFormat_r != TimeFormat::none )
 
  216      if ( dateFormat_r != DateFormat::none )
 
  218      str << _timeFormat( timeFormat_r );
 
  219      switch ( timeZoneFormat_r.asEnum() )
 
  221        case TimeZoneFormat::none:
 
  223        case TimeZoneFormat::name:
 
  230        case TimeZoneFormat::offset:
 
  231          str << _timeZoneFormat( TimeZoneFormat::offset );
 
  235    return doForm( 
str, base_r, 
_date );
 
 
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,...
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
static const ValueType day
static const ValueType month31
static const ValueType minute
base::EnumClass< EDateFormatDef > DateFormat
'enum class DateFormat'
static const ValueType month30
static const ValueType month
static const ValueType year366
base::EnumClass< ETimeZoneFormatDef > TimeZoneFormat
'enum class TimeZoneFormat'
std::string form(const std::string &format_r) const
Return string representation according to format as localtime.
static const ValueType month28
base::EnumClass< ETimeFormatDef > TimeFormat
'enum class TimeFormat'
static const ValueType month29
static const ValueType second
static const ValueType year
Temorarily change a locale category value.
LocaleGuard(int category_r, const std::string &value_r="C")
Ctor saving the current locale category value.
~LocaleGuard()
Dtor asserts the saved locale category value is restored.
String related utilities and Regular expression matching.
SolvableSpec & operator=(const SolvableSpec &)=default
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
TInt strtonum(const C_Str &str)
Parsing numbers from string.
std::ostream & node(std::ostream &out_r, const std::string &name_r, Node::Attr attr_r)
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpAsXmlOn(std::ostream &str, const Repository &obj)
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...