Skip to main content

Python combine dates , current date with different hour

Specification: I want to launch deployment script but not before 18:00 so every user can leave home. I want to lunch it today but with different time that gives To do it I think best way is t to combine with time(18,00) and then compare with Command of lauching is up to us so jsut for tests lets pass it in argvs:

.:w . code-block:: bash

python 16 35

import sys
from datetime import datetime, date,time

exe_time=datetime.combine(, time(ehour,eminute))
#or datetime.(,,,ehour,eminute)
print "time left:"
print (exe_time - current_time)

if exe_time<=current_time:
    print "executing..."


Comments powered by Disqus