Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. Sat Sep 2 03:32:13 2012 [pid 12461] CONNECT: Client "66.249.68.236"
  2. Sat Sep 2 03:32:13 2012 [pid 12460] [ftp] OK LOGIN: Client "66.249.68.236", anon password "gxxglxxxxt@google.com"
  3. Sat Sep 2 03:32:14 2012 [pid 12462] [ftp] OK DOWNLOAD: Client "66.249.68.236", "/pub/10.5524/100001_101000/100022/readme.txt", 451
  4.  
  5. def OnlyRecent(line):
  6. print time.strptime(line.split("[")[0].strip(),"%a %b %d %H:%M:%S %Y")
  7. print time.time()
  8. if time.strptime(line.split("[")[0].strip(),"%a %b %d %H:%M:%S %Y") < time.time():
  9. return True
  10. return False
  11.  
  12. (2012, 9, 2, 3, 32, 13, 5, 246, -1)
  13. 1347332968.08
  14. (2012, 9, 2, 3, 32, 13, 5, 246, -1)
  15. 1347332968.08
  16. (2012, 9, 2, 3, 32, 14, 5, 246, -1)
  17. 1347332968.08
  18.  
  19. >>> import time
  20. >>> time.mktime((2012, 9, 2, 3, 32, 13, 5, 246, -1))
  21. 1346527933.0
  22.  
  23. from datetime import datetime
  24. def OnlyRecent(line):
  25. return datetime.strptime(line.split("[")[0].strip(),"%a %b %d %H:%M:%S %Y") < datetime.now()
  26.  
  27. seven_days = datetime.timedelta(days=7)
  28.  
  29. def OnlyRecent(line):
  30. dt = datetime.datetime.strptime(line.split('[')[0].strip(), "%a %b %d %H:%M:%S %Y")
  31. return dt > datetime.datetime.now() - seven_days
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement