Created
January 1, 2014 02:43
-
-
Save dbehnke/8204447 to your computer and use it in GitHub Desktop.
My stardate inspired way to tell time... just for fun.. not to be used seriously.
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
from datetime import datetime | |
from datetime import timedelta | |
import time | |
def getearthdate(dt_now): | |
dt_begin = datetime(dt_now.year, 1, 1) | |
dt_end = datetime(dt_now.year + 1, 1, 1) | |
delta_year_length = dt_end - dt_begin | |
delta_progress = dt_now - dt_begin | |
percent = float(delta_progress.total_seconds()) / \ | |
float(delta_year_length.total_seconds()) * float(100.0) | |
return str(dt_now.year - 1900) + str("%08.5f" % percent) | |
while 1: | |
print("earthdate (localtime) = " + getearthdate(datetime.now())) | |
print("earthdate (+2 hours) = " + | |
getearthdate(datetime.now() + timedelta(hours=2))) | |
print("earthdate (UTC) = " + getearthdate(datetime.utcnow())) | |
time.sleep(1) | |
print("-----") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment