def parse_date(daystr):
    """ parse a timestring into a timestamp. """
    sec = 0
    min = 0
    hour = 0
    day = 0
    w = 0
    diff = 0
    prev = ''
    val = 0
    total = 0
    for c in daystr:
        if c not in ['s', 'm', 'h', 'd', 'w', 'y']:
            val += c
            continue
        if c == 'y':
            total += val * 3600 * 24 * 365
        if c == 'w':
            total += val * 3600 * 24 * 7
        elif c == 'd':
            total += val * 3600 * 24
        elif c == 'h':
            total += val * 3600
        elif c == 'm':
            total += val * 60
        else:
            total += val
        val = 0
    return total
