Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dates are displayed in the browser timezone #1001

Open
Kuruyia opened this issue May 16, 2023 · 0 comments
Open

Dates are displayed in the browser timezone #1001

Kuruyia opened this issue May 16, 2023 · 0 comments
Labels

Comments

@Kuruyia
Copy link
Contributor

Kuruyia commented May 16, 2023

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"
    }
  }
}
  1. Create a document in this collection with the following content:
{
  "date": 1684195200000
}
  1. 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

@Kuruyia Kuruyia added the bug label May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant