1
0
Fork 0
mirror of https://git.sr.ht/~cadence/NewLeaf synced 2026-03-05 12:01:38 +00:00

Support premiere videos on channel

This commit is contained in:
Cadence Ember 2021-07-01 23:42:53 +12:00
parent 7d3b79b1cd
commit 1ea86101fd
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
2 changed files with 26 additions and 6 deletions

View file

@ -191,6 +191,13 @@ def past_text_to_time(text):
def time_to_past_text(timestamp):
now = int(time.time())
diff = now - timestamp
# also allow for times in the future by using the same algorithm, then altering the output at the end
time_is_in_past = True
if diff < 0:
diff = -diff
time_is_in_past = False
units = [
["year", 365 * 24 * 60 * 60],
["month", 30 * 24 * 60 * 60],
@ -205,7 +212,10 @@ def time_to_past_text(timestamp):
if diff > unit_value or index + 1 >= len(units):
number = diff // unit_value
plural_unit = unit_name if number == 1 else unit_name + "s"
return "{} {} ago".format(number, plural_unit)
if time_is_in_past:
return "{} {} ago".format(number, plural_unit)
else:
return "in {} {}".format(number, plural_unit)
def get_language_label_from_url(url_string):
url = urlparse(url_string)