kuzzleio / kuzzle-admin-console

A SPA to administrate your Kuzzle: index and collection management, document creation, realtime subscription and permissions management
http://console.kuzzle.io
Apache License 2.0
61 stars 25 forks source link

Dates are displayed in the browser timezone #1001

Open Kuruyia opened 1 year ago

Kuruyia commented 1 year ago

When looking at a value whose property type is set to date in the collection mapping, the Kuzzle admin console automatically formats the timestamp to a human-readable date string.

The issue is that this string takes into account the timezone that the user agent is currently in, leading to false readings in some situations.

A prime example of that would be the nextExecution field, that can be seen in scheduled tasks (for the Kuzzle Scheduler plugin) or in scheduled workflows (for the Kuzzle Workflows plugin), which contains the timestamp at which the next execution of a task/workflow is planned:

image

In the above screenshot, the Kuzzle admin console incorrectly displays the next execution as taking place at 04 AM, where in reality it will be executed at 02 AM.

Expected Behavior

The displayed date is using the GMT timezone.

Current Behavior

The displayed date is using the user agent timezone.

Possible Solution

In places that formats the date using toLocaleString (DocumentListItem.vue, TimeSeries.vue, TableCell.vue), set the timeZone option to UTC, such as:

date.toLocaleString("en-GB", { timeZone: "UTC" });

Steps to Reproduce

  1. In an index, create a collection with the following mapping:
    {
    "dynamic": "true",
    "properties": {
    "date": {
      "type": "date"
    }
    }
    }
  2. Create a document in this collection with the following content:
    {
    "date": 1684195200000
    }
  3. Observe that the reported date is 16/05/2023, 02:00:00 (for CEST/GMT+2), where it should be 16/05/2023, 00:00:00.

Context (Environment)

Kuzzle version: 2.24.0 Node.js version: v16.18.0 Admin Console version: 4.3.2