Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from datetime import datetime
- def calculate_stardate():
- c = 48315
- b = 2371
- y = datetime.utcnow().year
- n = 366 if is_leap_year(y) else 365 # Define `is_leap_year` function to check leap year
- d = datetime.utcnow().timetuple().tm_yday
- star_date = c + (1000 * (y - b)) + (int(1000 / n * (d - 1)))
- day_progress = datetime.utcnow().timeofday().total_seconds() / 86400 # Convert to fraction of a day
- formatted_stardate = f"{star_date}.{str(day_progress)[2:5]}" # Adjust slice to match precision
- return formatted_stardate
- def is_leap_year(year):
- return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement