Last active
January 20, 2020 23:08
-
-
Save gkarthik/2852f66dc335d8533ff174614d03fca5 to your computer and use it in GitHub Desktop.
decimal year to datetime
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 ,timedelta | |
import sys | |
given_year = float(sys.argv[1]) | |
base = datetime(int(given_year),1,1) | |
year_rem = given_year - int(given_year) | |
calc_date = (base + timedelta(seconds = (base.replace(year = base.year+1) - base).total_seconds() * year_rem )) | |
print(calc_date.strftime("%d %b %Y")) |
Author
gkarthik
commented
Jan 20, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment