Changeset 6993c72 in OpenWorkouts-current for ow/utilities.py


Ignore:
Timestamp:
Feb 4, 2019, 1:10:40 PM (5 years ago)
Author:
Segundo Fdez <segun.2@…>
Branches:
current, feature/docs, master
Children:
d52ba50
Parents:
bf01534 (diff), 3357e47 (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:

Merge branch 'master' into feature/ui

# Conflicts:
# ow/templates/profile.pt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/utilities.py

    rbf01534 r6993c72  
    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.