OSDN Git Service

bug fix: -1 day ago if local clock delayed
authorHirotaka Kawata <hktechno@hotmail.com>
Mon, 8 Mar 2010 16:55:26 +0000 (01:55 +0900)
committerHirotaka Kawata <hktechno@hotmail.com>
Mon, 8 Mar 2010 16:55:26 +0000 (01:55 +0900)
twittertools.py

index 30bf5a3..9a7c15f 100644 (file)
@@ -83,8 +83,12 @@ class TwitterTools:
         return dt.strftime("%H:%M:%S")
     
     def get_time_ago(self, dt):
-        ago = datetime.datetime.now() - dt
+        now = datetime.datetime.now()
+
+        if now < dt:
+            return "Just now!"
         
+        ago = now - dt
         hours = ago.seconds / 3600
         minutes = ago.seconds / 60