mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-06 15:28:53 +00:00
Fixes localization weirdness with dates
This commit is contained in:
parent
d69ce8cbbd
commit
70a819951e
3 changed files with 2 additions and 24 deletions
|
@ -39,7 +39,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<p>
|
<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 %}
|
{% if date or book.first_published_date %}
|
||||||
<meta
|
<meta
|
||||||
itemprop="datePublished"
|
itemprop="datePublished"
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-footer-item">
|
<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>
|
</div>
|
||||||
{% if not moderation_mode %}
|
{% if not moderation_mode %}
|
||||||
<div class="card-footer-item">
|
<div class="card-footer-item">
|
||||||
|
|
|
@ -133,28 +133,6 @@ def get_uuid(identifier):
|
||||||
return "%s%s" % (identifier, uuid4())
|
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")
|
@register.filter(name="to_markdown")
|
||||||
def get_markdown(content):
|
def get_markdown(content):
|
||||||
""" convert markdown to html """
|
""" convert markdown to html """
|
||||||
|
|
Loading…
Reference in a new issue