Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/utils.py
Show First 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | def shorten_path(path): | ||||
sha256_re = r"([0-9a-f]{8})[0-9a-z]{56}" | sha256_re = r"([0-9a-f]{8})[0-9a-z]{56}" | ||||
sha1_re = r"([0-9a-f]{8})[0-9a-f]{32}" | sha1_re = r"([0-9a-f]{8})[0-9a-f]{32}" | ||||
ret = re.sub(sha256_re, r"\1...", path) | ret = re.sub(sha256_re, r"\1...", path) | ||||
return re.sub(sha1_re, r"\1...", ret) | return re.sub(sha1_re, r"\1...", ret) | ||||
def format_utc_iso_date(iso_date, fmt="%d %B %Y, %H:%M UTC"): | def format_utc_iso_date(iso_date, fmt="%d %B %Y, %H:%M:%S UTC"): | ||||
"""Turns a string representation of an ISO 8601 datetime string | """Turns a string representation of an ISO 8601 datetime string | ||||
to UTC and format it into a more human readable one. | to UTC and format it into a more human readable one. | ||||
For instance, from the following input | For instance, from the following input | ||||
string: '2017-05-04T13:27:13+02:00' the following one | string: '2017-05-04T13:27:13+02:00' the following one | ||||
is returned: '04 May 2017, 11:27 UTC'. | is returned: '04 May 2017, 11:27 UTC'. | ||||
Custom format string may also be provided | Custom format string may also be provided | ||||
as parameter | as parameter | ||||
▲ Show 20 Lines • Show All 360 Lines • Show Last 20 Lines |