12345678910 |
- def truncate_week(datetime):
- '''
- Truncates a date to the first day of an ISO 8601 week, i.e. monday.
- :params datetime: an initialized datetime object
- :return: `datetime` with the original day set to monday
- :rtype: :py:mod:`datetime` datetime object
- '''
- datetime = truncate(datetime, 'day')
- return datetime - timedelta(days=datetime.isoweekday() - 1)
|