Changeset d517001 in OpenWorkouts-current for ow/utilities.py
- Timestamp:
- Feb 15, 2019, 6:09:04 PM (5 years ago)
- Branches:
- current, feature/docs, master
- Children:
- d5429c5
- Parents:
- d459ee2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ow/utilities.py
rd459ee2 rd517001 13 13 from ZODB.blob import Blob 14 14 from splinter import Browser 15 16 from pyramid.i18n import TranslationStringFactory 17 18 _ = TranslationStringFactory('OpenWorkouts') 15 19 16 20 … … 263 267 return weeks.index(week) 264 268 return None 269 270 271 def part_of_day(dt): 272 """ 273 Given a datetime object (dt), return which part of the day was it 274 (morning, afternoon, evening, night), translated in the proper 275 """ 276 parts = { 277 _('Morning'): (5, 11), 278 _('Afternoon'): (12, 17), 279 _('Evening'): (18, 22), 280 _('Night'): (23, 4) 281 } 282 for key, value in parts.items(): 283 if value[0] <= dt.hour <= value[1]: 284 return key
Note: See TracChangeset
for help on using the changeset viewer.