Skip to content

Instantly share code, notes, and snippets.

@tgwaste
Last active July 26, 2020 18:13
Show Gist options
  • Save tgwaste/6ee9e62dae7ad09565af61d7576e4a19 to your computer and use it in GitHub Desktop.
Save tgwaste/6ee9e62dae7ad09565af61d7576e4a19 to your computer and use it in GitHub Desktop.
#!/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