From d748dc7d20683f0821e495bf50af2ce5364221cd Mon Sep 17 00:00:00 2001 From: gothack329 Date: Thu, 1 Mar 2018 23:24:24 +0800 Subject: [PATCH] update time format --- article/templates/article/detail.html | 2 +- .../__pycache__/timetonow.cpython-36.pyc | Bin 805 -> 814 bytes article/templatetags/timetonow.py | 6 +++--- templates/index.html | 2 +- userpage/templates/userpage/profile.html | 2 +- userpage/templates/userpage/update.html | 5 ----- 6 files changed, 6 insertions(+), 11 deletions(-) delete mode 100644 userpage/templates/userpage/update.html diff --git a/article/templates/article/detail.html b/article/templates/article/detail.html index 1bcefed..79166a4 100644 --- a/article/templates/article/detail.html +++ b/article/templates/article/detail.html @@ -41,7 +41,7 @@

{% if art %}{{art.title}}{% endif %}

          评论数:{{comments|length}}           - 发表于:{{art.publish_time|timetonow}}前 + 发表于:{{art.publish_time|timetonow}} {% ifequal request.user.id art.author_id.id %} {% endifequal %} diff --git a/article/templatetags/__pycache__/timetonow.cpython-36.pyc b/article/templatetags/__pycache__/timetonow.cpython-36.pyc index b2fa2073231423a1dee8340deb2a27783f9e9e88..593a633fb3da1675f81ff1826e00d3e22150ee65 100644 GIT binary patch delta 78 zcmZ3=wvLU{n3tF9pwx`0RU0|e7|l2s7#LJjo-SGWw6ix;fRBNplp7+lq5s+RZ9u`7 V6+k{ru%qqer1?O>&2tz#83FNa9C`o% delta 69 zcmZ3-wv>(2n3tE!Mr20R!i}71jJm803=FC%PnWFB6yRfEDCK}~H}pT7zU^fNkOLFx OXnQ$n{^q5Oos0mZ1r_W7 diff --git a/article/templatetags/timetonow.py b/article/templatetags/timetonow.py index 12f58db..6b4f233 100644 --- a/article/templatetags/timetonow.py +++ b/article/templatetags/timetonow.py @@ -15,11 +15,11 @@ def timetonow(value): delta = now-valuetime s = delta.seconds if s>86400: - return '%d天' % (int(s/86400)) + return '%d天前' % (int(s/86400)) elif s>3600: - return '%d小时' % (int(s/3600)) + return '%d小时前' % (int(s/3600)) elif s>120: - return '%d分钟' % (int(s/120)) + return '%d分钟前' % (int(s/120)) else: return '刚刚' diff --git a/templates/index.html b/templates/index.html index 2bf5680..a70a854 100644 --- a/templates/index.html +++ b/templates/index.html @@ -21,7 +21,7 @@

{% if title %}{{title}}{% endif %}

{{i.title}}

{{i.detail|striptags|truncatechars:500|safe}}

-  {{i.publish_time|timetonow}}前 +  {{i.publish_time|timetonow}}      {{i.author}}     diff --git a/userpage/templates/userpage/profile.html b/userpage/templates/userpage/profile.html index fc84c9b..fe4d162 100644 --- a/userpage/templates/userpage/profile.html +++ b/userpage/templates/userpage/profile.html @@ -97,7 +97,7 @@

{{i.title}}

{{i.detail|striptags|truncatechars:500|safe}}

-  {{i.publish_time|timetonow}}前 +  {{i.publish_time|timetonow}}      {{i.author}}     diff --git a/userpage/templates/userpage/update.html b/userpage/templates/userpage/update.html deleted file mode 100644 index 0a714a8..0000000 --- a/userpage/templates/userpage/update.html +++ /dev/null @@ -1,5 +0,0 @@ - -{% block content%} - - -{% endblock %} \ No newline at end of file