Fixes localization weirdness with dates

This commit is contained in:
Mouse Reeve 2021-04-19 16:18:29 -07:00
parent d69ce8cbbd
commit 70a819951e
3 changed files with 2 additions and 24 deletions

View file

@ -39,7 +39,7 @@
{% endif %}
<p>
{% with date=book.published_date|date:'M jS Y' publisher=book.publishers|join:', ' %}
{% with date=book.published_date|date:'M j Y' publisher=book.publishers|join:', ' %}
{% if date or book.first_published_date %}
<meta
itemprop="datePublished"

View file

@ -65,7 +65,7 @@
</div>
<div class="card-footer-item">
<a href="{{ status.remote_id }}">{{ status.published_date | post_date }}</a>
<a href="{{ status.remote_id }}">{{ status.published_date|timesince }}</a>
</div>
{% if not moderation_mode %}
<div class="card-footer-item">

View file

@ -133,28 +133,6 @@ def get_uuid(identifier):
return "%s%s" % (identifier, uuid4())
@register.filter(name="post_date")
def time_since(date):
""" concise time ago function """
if not isinstance(date, datetime):
return ""
now = timezone.now()
if date < (now - relativedelta(weeks=1)):
formatter = "%b %-d"
if date.year != now.year:
formatter += " %Y"
return date.strftime(formatter)
delta = relativedelta(now, date)
if delta.days:
return "%dd" % delta.days
if delta.hours:
return "%dh" % delta.hours
if delta.minutes:
return "%dm" % delta.minutes
return "%ds" % delta.seconds
@register.filter(name="to_markdown")
def get_markdown(content):
""" convert markdown to html """