SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from datetime import datetime
  2.  
  3.  
  4. class TimeManager:
  5.  
  6.     def __init__(self):
  7.         self.time_in = datetime.now()
  8.        
  9.         self.time_out = datetime.now()
  10.  
  11.     def __enter__(self):
  12.         self.delta = self.time_in - self.time_out
  13.         return self.time_in, self.time_out, self.delta
  14.  
  15.     def __exit__(self, exc_type, exc_val, exc_tb):
  16.         pass
  17.  
  18.  
  19. with TimeManager() as a:
  20.     print(a[0].strftime("%Y-%m-%d-%H.%M.%S"))
  21.     print(a[1].strftime("%Y-%m-%d-%H.%M.%S"))
  22.     print(a[2])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top