Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2934b44ca1
Fetching contributors…

Cannot retrieve contributors at this time

27 lines (19 sloc) 0.581 kb
import time
from datetime import datetime
def maybe_list(value):
if hasattr(value, "__iter__"):
return value
if value is None:
return []
return [value]
def mkey(names):
return ":".join(maybe_list(names))
def dt_to_timestamp(dt):
"""Convert :class:`datetime` to UNIX timestamp."""
return time.mktime(dt.timetuple())
def maybe_datetime(timestamp):
"""Convert datetime to timestamp, only if timestamp
is a datetime object."""
if isinstance(timestamp, datetime):
return dt_to_timestamp(timestamp)
return timestamp
Jump to Line
Something went wrong with that request. Please try again.