qgis / QGIS-Django

Django project for QGIS related activities such as plugin repository
http://qgis.org
GNU General Public License v2.0
89 stars 59 forks source link

Fix different displayed date #315

Closed Xpirix closed 9 months ago

Xpirix commented 10 months ago

This fix is for the following issue:

In the current PR, all dates in the plugin list, the plugin details and the plugin version details use the same timezone provided by the filter local_timezone. In the plugin list, the date without time format is kept. A distance formatting (time since) using moment.min.js is used when it doesn't exceed one day.

Please find below the screenshots for these 3 pages:

image

image

image

Xpirix commented 10 months ago

Please find below the updated screenshot after fixing the displayed date in the 'Created on' column: image

agiudiceandrea commented 10 months ago

@Xpirix, thanks for looking at the issue! It is not clear to me why the "Created on" column displays "Nov 30, 2023" while the plugin has been created on "Nov 28, 2023".

Xpirix commented 10 months ago

@agiudiceandrea , Thanks for your feedback. Indeed, the plugin was uploaded on different dates in my development environment but I did not update all screenshots. Please find below the updated screenshots for all of these pages for a newly uploaded plugin:

image

image

image

Xpirix commented 9 months ago

@dimasciput Thank you. I checked the plugin list but I noticed that the dates are in a raw format. I see that the file local_timezone.js used in the browser is different from the one in the code. I cleared my cache but still got the same format. However, the right file is implemented in the server.

image

agiudiceandrea commented 9 months ago

I checked the plugin list but I noticed that the dates are in a raw format

I can confirm the issue. The local_timezone.js (https://plugins.qgis.org/static/js/local_timezone.js) retrieved from the server is the old one:

// Replace the date with local timezone

$(".user-timezone").each(function (i) {
  let localDate = toUserTimeZone($(this).text());
  $(this).text(localDate);
})

function toUserTimeZone(date) {
  try {
    date = new Date(date);
    let options = {
      year: 'numeric', month: 'short', day: 'numeric',
      hour: '2-digit', minute: '2-digit',
      timeZoneName: 'short'
    }
    return date.toLocaleDateString([], options);
  } catch (e) {
    return date;
  }
}

The response headers report: last-modified: Thu, 08 Sep 2022 18:59:37 GMT.

Maybe a cloudflare cache issue?

agiudiceandrea commented 9 months ago

I can confirm the issue.

The issue has been fixed with https://github.com/qgis/QGIS-Django/pull/335.