def time_for(s):
    """
    Given a time stirng, returns a number of seconds that
    corresponds to that time. For a plain number string
    it returns the string as an int otherwise it converts
    based on the last char of the string when it is one of
    the following:
    m -> Minutes
    h -> hours
    d -> days
    w -> weeks
    """
    try:
        return int(s)
    except:
        pass
    denom = s[-1]
    m = 1
    value = s[:-1]
    if denom == 'm':
        m = 60
    elif denom == 'h':
        m = 3600
    elif denom == 'd':
        m = 86400
    elif denom == 'w':
        m = 604800
    else:
        raise ValueError(
            "Invalid time denomination! Must be m, h, d, w or nothing not {}".format(denom))
    return int(value) * m