diff --git a/qgis-app/plugins/templates/plugins/plugin_list.html b/qgis-app/plugins/templates/plugins/plugin_list.html index f2e28b06..c959d4f8 100644 --- a/qgis-app/plugins/templates/plugins/plugin_list.html +++ b/qgis-app/plugins/templates/plugins/plugin_list.html @@ -94,7 +94,7 @@

{% if title %}{{title}}{% else %}{% trans "All plugins" %}{% endif %}

{% if object.author %} {{ object.author }} {% endif %} - {{ object.latest_version_date|local_timezone:"SHORT" }} + {{ object.latest_version_date|local_timezone:"SHORT_NATURAL_DAY" }} {{ object.created_on|local_timezone:"SHORT" }}
({{ object.rating_votes }})
{% if object.stable %}{{ object.stable.version }}{% else %}—{% endif %} diff --git a/qgis-app/plugins/templatetags/local_timezone.py b/qgis-app/plugins/templatetags/local_timezone.py index 1fabb173..8463a9be 100644 --- a/qgis-app/plugins/templatetags/local_timezone.py +++ b/qgis-app/plugins/templatetags/local_timezone.py @@ -9,8 +9,10 @@ def local_timezone(date, args="LONG"): try: utcdate = date.astimezone(pytz.utc).isoformat() - if args and str(args).lower() == "short": - result = '%s' % (utcdate,) + if args and str(args) == "SHORT": + result = '%s' % (utcdate,) + elif args and str(args) == "SHORT_NATURAL_DAY": + result = '%s' % (utcdate,) else: result = '%s' % (utcdate,) except AttributeError: diff --git a/qgis-app/static/js/local_timezone.js b/qgis-app/static/js/local_timezone.js index a8605b7f..6b6cca21 100644 --- a/qgis-app/static/js/local_timezone.js +++ b/qgis-app/static/js/local_timezone.js @@ -5,12 +5,17 @@ $(".user-timezone").each(function (i) { $(this).text(localDate); }) -$(".short-user-timezone").each(function (i) { - let localDate = toUserTimeZone($(this).text(), false); +$(".user-timezone-short").each(function (i) { + let localDate = toUserTimeZone($(this).text(), withTime=false); $(this).text(localDate); }) -function toUserTimeZone(date, withTime=true) { +$(".user-timezone-short-naturalday").each(function (i) { + let localDate = toUserTimeZone($(this).text(), withTime=false, isNaturalDay=true); + $(this).text(localDate); +}) + +function toUserTimeZone(date, withTime=true, isNaturalDay=false) { try { date = new Date(date); let options = { @@ -23,7 +28,7 @@ function toUserTimeZone(date, withTime=true) { } const diffInDays = moment().diff(moment(date), 'days'); - if (diffInDays <= 1 && !withTime) { + if (diffInDays <= 1 && isNaturalDay) { const distance = moment(date).fromNow(); return distance }