def convert_timestamp(obj, default_tz='America/Chicago'):
"""Makes a Bark timestamp from an object.
If the object is not timezone-aware, the timezone is set to be `default_tz.`
Args:
obj: time object; see :meth:`timestamp_to_datetime` for supported types
default_tz (str): timezone to use if `obj` is timezone-naive; must be a
string from the `tz database
<https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>`_.
Returns:
Arrow: Bark timestamp
"""
dt = timestamp_to_datetime(obj)
if dt.tzinfo:
return arrow.get(dt).isoformat()
else:
return arrow.get(dt, default_tz).isoformat()
评论列表
文章目录