Skip to content

Instantly share code, notes, and snippets.

@dbehnke
Created January 1, 2014 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbehnke/8204447 to your computer and use it in GitHub Desktop.
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.
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