Author: aschnell Date: Fri Aug 31 15:48:32 2007 New Revision: 7058 URL: http://svn.opensuse.org/viewcvs/zypp?rev=7058&view=rev Log: - use zypp date class Added: trunk/libzypp-bindings/examples/python/date.py (with props) Modified: trunk/libzypp-bindings/README trunk/libzypp-bindings/swig/Date.i Modified: trunk/libzypp-bindings/README URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/README?rev=7058&r1=7057&r2=7058&view=diff ============================================================================== --- trunk/libzypp-bindings/README (original) +++ trunk/libzypp-bindings/README Fri Aug 31 15:48:32 2007 @@ -2,27 +2,18 @@ Attempt to create generated bindings for libzypp. Not restricted to one language. -Author: dmacvicar@suse.de - -Notes: - -- Some classes are not wrapped but converted to - equivalents: - -Usage: - -Requires swig and ruby installed. +Authors: dmacvicar@suse.de + aschnell@suse.de Ruby Notes ========== * API tries to follow ruby standards: -* zypp::Pathname -> std Pathname in ruby -* zypp::Date -> std Time in ruby -* ResStore does not implement iterators but: +* Containers do not implement iterators but: * each - * each_by_name + * to_a * etc * lower case methods, ie: ZYppFactory::instance.get_zypp instead of ZYppFactory::instance()->getZYpp() z.initialize_target("/") for z.initializeTarget("/") + Added: trunk/libzypp-bindings/examples/python/date.py URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/examples/python/date.py?rev=7058&view=auto ============================================================================== --- trunk/libzypp-bindings/examples/python/date.py (added) +++ trunk/libzypp-bindings/examples/python/date.py Fri Aug 31 15:48:32 2007 @@ -0,0 +1,10 @@ +#!/usr/bin/python + +from zypp import Date + +print Date() + +d = Date.now() +print d +print d.form("%F %T") + Modified: trunk/libzypp-bindings/swig/Date.i URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/Date.i?rev=7058&r1=7057&r2=7058&view=diff ============================================================================== --- trunk/libzypp-bindings/swig/Date.i (original) +++ trunk/libzypp-bindings/swig/Date.i Fri Aug 31 15:48:32 2007 @@ -1,17 +1,20 @@ -#ifdef SWIGRUBY +#if defined(SWIGPYTHON) || defined(SWIGRUBY) +%rename Date::asString "__str__"; +#endif -%typemap(in) Date { - Date::ValueType seconds = (Date::ValueType) NUM2INT( rb_funcall( $input, rb_intern("to_i"), 0, 0) ); - $1 = Date(seconds); -} - -%typemap(out) Date { - // Time works without require - VALUE klass = rb_const_get( rb_cObject, rb_intern("Time")); - VALUE rbtimenum = INT2NUM( (Date::ValueType) $1 ); - $result = rb_funcall( klass, rb_intern("at"), 1, rbtimenum); -} +class Date +{ +public: -#endif + Date(); + Date(const std::string & seconds_r); + + static Date now(); + + std::string form(const std::string & format_r) const; + std::string asString() const; + std::string asSeconds() const; + +}; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org