def som(date, offset=0):
    """
    Returns the first date of the month for the given date, then optionally 
    offsets it by :code:`offset` months. 

    Example
    ------------
    >>> today = datetime.date(2020, 1, 15)
    >>> som(today)
    datetime.date(2020, 1, 1) #start of the current month

    >>> som(today, 1):
    datetime.date(2020, 2, 1) #first of February

    >>> som(today, -1):
    datetime.date(2019, 12, 1) #start of the previous month
    """
    return date.replace(year=date.year + (date.month + offset - 1) // 12,
        month=(date.month - 1 + 12 * date.year + offset) % 12 + 1, day=1)
