Changeset 3357e47 in OpenWorkouts-current for ow/utilities.py


Ignore:
Timestamp:
Feb 4, 2019, 12:38:29 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
6993c72
Parents:
1183d5a (diff), 5cf5787 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged patches from darcs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/utilities.py

    r1183d5a r3357e47  
    22import os
    33import logging
     4import calendar
    45import subprocess
    56from datetime import datetime, timedelta
     
    234235    week_days = [first_day + timedelta(days=i) for i in range(7)]
    235236    return week_days
     237
     238
     239def get_month_week_number(day):
     240    """
     241    Given a datetime object (day), return the number of week the day is
     242    in the current month (week 1, 2, 3, etc)
     243    """
     244    weeks = calendar.monthcalendar(day.year, day.month)
     245    for week in weeks:
     246        if day.day in week:
     247            return weeks.index(week)
     248    return None
Note: See TracChangeset for help on using the changeset viewer.