Author: mlandres Date: Wed Nov 14 14:33:48 2007 New Revision: 7808 URL: http://svn.opensuse.org/viewcvs/zypp?rev=7808&view=rev Log: Output date strings in UTF-8. Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/VERSION branches/SuSE-SLE-10-SP2-Branch/libzypp/package/libzypp.changes branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Date.cc Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/VERSION URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/VERSION?rev=7808&r1=7807&r2=7808&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP2-Branch/libzypp/VERSION (original) +++ branches/SuSE-SLE-10-SP2-Branch/libzypp/VERSION Wed Nov 14 14:33:48 2007 @@ -49,5 +49,5 @@ m4_define([LIBZYPP_MINOR], [30]) m4_define([LIBZYPP_COMPATMINOR], [30]) dnl ================================================== -m4_define([LIBZYPP_PATCH], [2]) +m4_define([LIBZYPP_PATCH], [3]) dnl ================================================== Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/package/libzypp.changes URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/package/libzypp.changes?rev=7808&r1=7807&r2=7808&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP2-Branch/libzypp/package/libzypp.changes (original) +++ branches/SuSE-SLE-10-SP2-Branch/libzypp/package/libzypp.changes Wed Nov 14 14:33:48 2007 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Wed Nov 14 14:23:23 CET 2007 - ma@suse.de + +- Output date strings in UTF-8. (#339423) +- version 2.30.3 +- revision 7808 + +------------------------------------------------------------------- Tue Nov 6 14:43:54 CET 2007 - ma@suse.de - Throw an exception when adding a new source with an already Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Date.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Date.cc?rev=7808&r1=7807&r2=7808&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Date.cc (original) +++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Date.cc Wed Nov 14 14:33:48 2007 @@ -38,8 +38,56 @@ std::string Date::form( const std::string & format_r ) const { static char buf[1024]; + + static std::string lastLocale; + static std::string needLocale; + const char * tmp = ::setlocale( LC_TIME, NULL ); + std::string thisLocale( tmp ? tmp : "" ); + + if ( thisLocale != lastLocale ) + { + // locale changes since last call. compute new utf-8 locale + if ( thisLocale.find( "UTF-8" ) != std::string::npos + || thisLocale.find( "utf-8" ) != std::string::npos + || thisLocale == "POSIX" + || thisLocale == "C" + || thisLocale == "" ) + { + // is UTF-8 or C or POSIX + needLocale = thisLocale; + } + else + { + // language[_territory][.codeset][@modifier] + // add/exchange codeset with UTF-8 + needLocale = ".UTF-8"; + std::string::size_type loc = thisLocale.find_first_of( ".@" ); + if ( loc != std::string::npos ) + { + // prepend language[_territory] + needLocale = thisLocale.substr( 0, loc ) + needLocale; + loc = thisLocale.find_last_of( "@" ); + if ( loc != std::string::npos ) + { + // append [@modifier] + needLocale += thisLocale.substr( loc ); + } + } + else + { + // append ".UTF-8" + needLocale = thisLocale + needLocale; + } + } + lastLocale = thisLocale; + } + + if ( needLocale != lastLocale ) + ::setlocale( LC_TIME, needLocale.c_str() ); if ( ! strftime( buf, 1024, format_r.c_str(), localtime( &_date ) ) ) - return std::string(); + *buf = '\0'; + if ( needLocale != lastLocale ) + ::setlocale( LC_TIME, lastLocale.c_str() ); return buf; } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org