timeStampDelta.py

# -*- coding: utf-8 -*-
""" timeStampDelta.py
Copies datetime deltas to clipboard each time user presses enter
"""

import win32clipboard
from datetime import datetime, timedelta

def main():
    """  ["Code #3:" Python | datetime.timedelta() function](https://www.geeksforgeeks.org/python-datetime-timedelta-function/) """
    dt0 = datetime.now()
    print ("dt0 = %s\n Hit ENTER to UPDATE \nHit q & press enter to quit!\n"%(dt0))

    while True:
        instr = input("\n")
        # tdelta = time.time() - t0
        dtn = datetime.now() 
        tdelta = dtn - dt0


        if instr.startswith('q'): break
        outStr = "dtn = %s    tdelta = %s"%(dtn,tdelta)
        
        to_clipboard(outStr)
        print(outStr)

def to_clipboard(txt):
    """  https://stackoverflow.com/a/68563250/601770 """ 
    win32clipboard.OpenClipboard()
    win32clipboard.EmptyClipboard()
    win32clipboard.SetClipboardText(txt)
    win32clipboard.CloseClipboard()

if __name__ == '__main__':
    main()

#python, #time