From 28855e9a81e03539b9f8610d0e7c1ace50b8a3cb Mon Sep 17 00:00:00 2001
From: Thor77 <xXThor77Xx@gmail.com>
Date: Sun, 12 Jun 2016 17:52:44 +0200
Subject: [PATCH] use datetime.timedelta for Client.onlinetime instead of int

* get rid of all the converting-stuff
---
 tsstats/client.py |  5 +++--
 tsstats/log.py    | 11 +++--------
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/tsstats/client.py b/tsstats/client.py
index f6da66f..85c0b05 100644
--- a/tsstats/client.py
+++ b/tsstats/client.py
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 
+import datetime
 import logging
 from collections import MutableMapping
 
@@ -70,12 +71,12 @@ class Client(object):
         self.identifier = identifier
         self.nick = nick
         self.connected = 0
-        self.onlinetime = 0
+        self.onlinetime = datetime.timedelta()
         self.kicks = 0
         self.pkicks = 0
         self.bans = 0
         self.pbans = 0
-        self.last_seen = 0
+        self.last_seen = None
         # private
         self._last_connect = 0
 
diff --git a/tsstats/log.py b/tsstats/log.py
index c4af8f5..08570f6 100644
--- a/tsstats/log.py
+++ b/tsstats/log.py
@@ -68,10 +68,8 @@ def parse_log(log_path, ident_map=None, clients=None, online_dc=True):
             logger.debug('No match: "%s"', line)
             continue
         match = match.groupdict()
-        stripped_time = datetime.strptime(match['timestamp'],
-                                          log_timestamp_format)
-        logdatetime = int((stripped_time - datetime(1970, 1, 1))
-                          .total_seconds())
+        logdatetime = datetime.strptime(match['timestamp'],
+                                        log_timestamp_format)
         message = match['message']
         if message.startswith('client'):
             nick, clid = re_dis_connect.findall(message)[0]
@@ -95,10 +93,7 @@ def parse_log(log_path, ident_map=None, clients=None, online_dc=True):
     if online_dc:
         for client in clients:
             if client.connected:
-                client.disconnect(
-                    int((datetime.utcnow() - datetime(1970, 1, 1))
-                        .total_seconds())
-                )
+                client.disconnect(datetime.utcnow())
                 client.connected += 1
     logger.debug('Finished parsing of %s', log_file.name)
     return clients