Last active
October 27, 2022 13:25
-
-
Save RackReaver/8c3132841c073bb1f8c736e5d41ddd1a to your computer and use it in GitHub Desktop.
python:function: get the current quarter number
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 | |
# Get quarter number | |
get_current_quarter_number(): | |
today = int(datetime.now().strftime('%m')) | |
if today == 1 or today == 2 or today == 3: | |
quarter_number = 1 | |
elif today == 4 or today == 5 or today == 6: | |
quarter_number = 2 | |
elif today == 7 or today == 8 or today == 9: | |
quarter_number = 3 | |
elif today == 10 or today == 11 or today == 12: | |
quarter_number = 4 | |
return quarter_number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can also be done with match case for being less redundant I think: