Last active
July 26, 2020 18:13
-
-
Save tgwaste/6ee9e62dae7ad09565af61d7576e4a19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os, sys, time | |
# get tomorrow | |
tom = int(time.time()) + 86400; | |
# get target time | |
target = time.strftime("%Y%m%d_05:36:00", time.localtime(float(tom))) | |
# get epoch of target | |
pattern = '%Y%m%d_%H:%M:%S' | |
epoch = int(time.mktime(time.strptime(target, pattern))) | |
# get divergence of now and then | |
seconds = int(epoch) - int(time.time()) | |
# get hours until sunrise | |
hours = seconds / 60 / 60 | |
# print hours till sunrise | |
print hours,'hours till sunrise' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment