Created
June 15, 2016 15:14
-
-
Save bharadwaj-raju/40751f84d90e2a7d1935747f6a7c15f3 to your computer and use it in GitHub Desktop.
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
def get_time_of_day(level=3): | |
''' | |
For detail level 2: | |
06 to 20: day | |
20 to 06: night | |
''' | |
''' | |
For detail level 3: | |
06 to 17: day | |
17 to 20: evening | |
20 to 06: night | |
''' | |
''' | |
For detail level 4: | |
06 to 08: morning | |
08 to 17: day | |
17 to 20: evening | |
20 to 06: night | |
''' | |
current_time = datetime.datetime.now() | |
if level == 3: | |
if current_time.hour in range(6, 17): | |
return 'day' | |
elif current_time.hour in range(17, 20): | |
return 'evening' | |
else: | |
return 'night' | |
elif level == 4: | |
if current_time.hour in range(6, 8): | |
return 'morning' | |
elif current_time.hour in range(8, 17): | |
return 'day' | |
elif current_time.hour in range(17, 20): | |
return 'evening' | |
else: | |
return 'night' | |
else: | |
if current_time.hour in range(6, 20): | |
return 'day' | |
else: | |
return 'night' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment