Last active
January 7, 2022 08:55
-
-
Save darkmastermindz/770b0109c108aff492c13a5802926001 to your computer and use it in GitHub Desktop.
Snippet Calculates Level Based on Birthday with Example
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 | |
birthday_yday=38 # Birthday of the year, Feb 7th here for example | |
birthday_year = 2001 | |
day_of_year = datetime.now().timetuple().tm_yday | |
current_year = datetime.now().year | |
# TODO: Switch between lvl pre / post new years | |
# TODO: adjust for leap year | |
# adjust for new year block (post year) | |
if day_of_year < birthday_yday: | |
current_year = datetime.now().year - 1 | |
day_of_year = day_of_year + 365 | |
print((float(current_year - birthday_year) + (float(day_of_year)) / float(365 + birthday_yday))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment