import re


def calculate_minutes(val):
    """Calculate the number of minutes

    ex. '1h' -> 60 minutes
    """
    minutes = None
    b, m, p = re.split('(\d+)', val)

    if p == 'min':
        minutes = int(m) * 1                    # minutes
    elif p == 'h':
        minutes = int(m) * 60                   # hours
    elif p == 'd':
        minutes = int(m) * 60 * 24              # days
    elif p == 'w':
        minutes = int(m) * 60 * 24 * 7          # weeks
    else:
        minutes = int(m) * 60 * 24 * 7 * 30     # months

    return minutes