Python bindings: cleanup whitespace
[babeltrace.git] / bindings / python / babeltrace.i.in
index 4ead2980563f4534800f33f3f1d4a78810c2d316..724ed45d7e5d76351cdf905ca75e2690b57c9253 100644 (file)
@@ -653,6 +653,7 @@ _scopes = [CTFScope.EVENT_FIELDS, CTFScope.EVENT_CONTEXT, CTFScope.STREAM_EVENT_
        CTFScope.STREAM_EVENT_HEADER, CTFScope.STREAM_PACKET_CONTEXT, CTFScope.TRACE_PACKET_HEADER]
 
 import collections
+from datetime import datetime
 class Event(collections.Mapping):
        """
        This class represents an event from the trace.
@@ -683,6 +684,15 @@ class Event(collections.Mapping):
                """
                return _bt_ctf_get_timestamp(self._e)
 
+       @property
+       def datetime(self):
+               """
+               Return a datetime object based on the event's
+               timestamp. Note that the datetime class' precision
+               is limited to microseconds.
+               """
+               return datetime.fromtimestamp(self.timestamp / 1E9)
+
        def field_with_scope(self, field_name, scope):
                """
                Get field_name's value in scope.
@@ -810,7 +820,7 @@ class Event(collections.Mapping):
        def _field_list_with_scope(self, scope):
                fields = []
                scope_ptr = _bt_ctf_get_top_level_scope(self._e, scope)
-               
+
                # Returns a list [list_ptr, count]. If list_ptr is NULL, SWIG will only
                # provide the "count" return value
                count = 0
This page took 0.024813 seconds and 4 git commands to generate.