def calculate_start_date(display_since):
    """
    Private function
    Returns the datetime of display_since argument in MYSQL datetime format
    calculated according to the local time.
    :param display_since: =  all= no filtering
                            nd = n days ago
                            nw = n weeks ago
                            nm = n months ago
                            ny = n years ago
                            where n is a single digit number
    :return: string of wanted datetime.
            If 'all' given as argument, will return datetext_default
            datetext_default is defined in miscutils/lib/dateutils and
            equals 0000-00-00 00:00:00 => MySQL format
            If bad arguement given, will return datetext_default
            If library 'dateutil' is not found return datetext_default
            and register exception.
    """
    time_types = {'d': 0, 'w': 0, 'm': 0, 'y': 0}
    today = datetime.today()
    try:
        nb = int(display_since[:-1])
    except:
        return datetext_default
    if display_since in [None, 'all']:
        return datetext_default
    if str(display_since[-1]) in time_types:
        time_type = str(display_since[-1])
    else:
        return datetext_default
    # year
    if time_type == 'y':
        if (int(display_since[:-1]) > today.year -
                1) or (int(display_since[:-1]) < 1):
            #   1 < nb years < 2008
            return datetext_default
        else:
            final_nb_year = today.year - nb
            yesterday = today.replace(year=final_nb_year)
    # month
    elif time_type == 'm':
        try:
            from dateutil.relativedelta import relativedelta
        except ImportError:
            # The dateutil library is only recommended: if not
            # available, then send warning about this.
            register_exception(alert_admin=True)
            return datetext_default
        # obtain only the date: yyyy-mm-dd
        date_today = datetime.now().date()
        final_date = date_today - relativedelta(months=nb)
        yesterday = today.replace(
            year=final_date.year,
            month=final_date.month,
            day=final_date.day)
    # week
    elif time_type == 'w':
        delta = timedelta(weeks=nb)
        yesterday = today - delta
    # day
    elif time_type == 'd':
        delta = timedelta(days=nb)
        yesterday = today - delta
    return yesterday.strftime("%Y-%m-%d %H:%M:%S")