- use zypp date class
authorArvin Schnell <aschnell@suse.de>
Fri, 31 Aug 2007 13:48:32 +0000 (13:48 +0000)
committerArvin Schnell <aschnell@suse.de>
Fri, 31 Aug 2007 13:48:32 +0000 (13:48 +0000)
README
examples/python/date.py [new file with mode: 0755]
swig/Date.i

diff --git a/README b/README
index ff69c64..3512296 100644 (file)
--- a/README
+++ b/README
@@ -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("/")
+
diff --git a/examples/python/date.py b/examples/python/date.py
new file mode 100755 (executable)
index 0000000..965d2f3
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+
+from zypp import Date
+
+print Date()
+
+d = Date.now()
+print d
+print d.form("%F %T")
+
index 12717de..cd63399 100644 (file)
@@ -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);
-}
+class Date
+{
+public:
 
-%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);
-}
+    Date();
+    Date(const std::string & seconds_r);
 
-#endif
+    static Date now();
+
+    std::string form(const std::string & format_r) const;
+    std::string asString() const;
+    std::string asSeconds() const;
+
+};