chiark / gitweb /
systemd-python: _reader now takes unix timestamp in seconds
authorSteven Hiscocks <steven@hiscocks.me.uk>
Sat, 16 Feb 2013 19:10:49 +0000 (19:10 +0000)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 22 Feb 2013 15:57:44 +0000 (16:57 +0100)
src/python-systemd/_reader.c
src/python-systemd/journal.py

index 7aa638b0766edce9c92859a530a389fbd4277b33..95e60941622356ac2d5f3a35cd04e19b46550070 100644 (file)
@@ -336,14 +336,17 @@ Journal_seek(Journal *self, PyObject *args, PyObject *keywds)
 PyDoc_STRVAR(Journal_seek_realtime__doc__,
 "seek_realtime(realtime) -> None\n\n"
 "Seek to nearest matching journal entry to `realtime`. Argument\n"
-"`realtime` can must be an integer unix timestamp in usecs.");
+"`realtime` can must be an integer unix timestamp.");
 static PyObject *
 Journal_seek_realtime(Journal *self, PyObject *args)
 {
-    uint64_t timestamp;
-    if (! PyArg_ParseTuple(args, "K", &timestamp))
+    double timedouble;
+    if (! PyArg_ParseTuple(args, "d", &timedouble))
         return NULL;
 
+    uint64_t timestamp;
+    timestamp = (uint64_t) (timedouble * 1.0E6);
+
     if ((int64_t) timestamp < 0LL) {
         PyErr_SetString(PyExc_ValueError, "Time must be positive integer");
         return NULL;
index 279662e6a674f295e464d76938588f7b1e247f68..ab8661e987343f636f3fcd5351b72fe86120cd74 100644 (file)
@@ -126,7 +126,7 @@ class Journal(_Journal):
 
     def seek_realtime(self, timestamp):
         if isinstance(timestamp, datetime.datetime):
-            timestamp = int(timestamp.strftime("%s%f"))
+            timestamp = float(timestamp.strftime("%s.%f"))
         return super(Journal, self).seek_realtime(timestamp)
 
     def seek_monotonic(self, timestamp, bootid=None):