def get_epoch_time_from_str(s):
try:<EOL><INDENT>return int(s)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>if s.startswith('<STR_LIT:->'):<EOL><INDENT>chars = {'<STR_LIT:d>': <NUM_LIT> * <NUM_LIT> * <NUM_LIT>,<EOL>'<STR_LIT:h>': <NUM_LIT> * <NUM_LIT>,<EOL>'<STR_LIT:m>': <NUM_LIT>,<EOL>'<STR_LIT:s>': <NUM_LIT:1>}<EOL>m = chars.get(s[-<NUM_LIT:1>])<EOL>if m:<EOL><INDENT>n = float(s[<NUM_LIT:1>:-<NUM_LIT:1>])<EOL>secs = int(n * m)<EOL>now = int(time.time())<EOL>return max((now - secs), <NUM_LIT:0>)<EOL><DEDENT><DEDENT><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>raise ValueError("<STR_LIT>" % s)<EOL>
Convert a string into epoch time. Examples of valid strings:

        1418350671  # already epoch time
        -12s        # 12 seconds ago
        -5.4m       # 5.4 minutes ago