def push_time(ts): if not ts: return None ts = ' '.join(ts.split()[-2:]) yr = datetime.datetime.now().year # XXX this may go wrong at 12/31 -> 1/1 ts = '%d/%s' % (yr, ts) dt = datetime.datetime.strptime(ts, PUSHFMT) dt = utc(dt) return dt.strftime(ISOFMT)
def post_time(ts): if not ts: return now() dt = datetime.datetime.strptime(ts, POSTFMT) dt = utc(dt) return dt.strftime(ISOFMT)