Pretty-format the given timestamp (to be printed or logged hereafter). If tz, the timestamp will be converted to local time. Format: YYYY-MM-DD HH:MM TZ
(timestamp, tz=True)
| 194 | |
| 195 | |
| 196 | def pretty_ts(timestamp, tz=True): |
| 197 | """Pretty-format the given timestamp (to be printed or logged hereafter). |
| 198 | If tz, the timestamp will be converted to local time. |
| 199 | Format: YYYY-MM-DD HH:MM TZ""" |
| 200 | dt = timestamp |
| 201 | if not isinstance(timestamp, datetime.datetime): |
| 202 | dt = ts_to_dt(timestamp) |
| 203 | if tz: |
| 204 | dt = dt.astimezone(dateutil.tz.tzlocal()) |
| 205 | return dt.strftime('%Y-%m-%d %H:%M %Z') |
| 206 | |
| 207 | |
| 208 | def ts_add(ts, td): |
no test coverage detected