palantir/blueprint

Will TimePicker support locale representations?

Open

#6 450 ouverte le 9 oct. 2023

Voir sur GitHub
 (3 commentaires) (1 réaction) (0 assignés)TypeScript (2 167 forks)batch import
P2Package: datetimeType: feature requestType: questionhelp wanted

Métriques du dépôt

Stars
 (20 263 stars)
Métriques de merge PR
 (Merge moyen 43j 10h) (27 PRs mergées en 30 j)

Description

Environment

  • Package version(s): @blueprint/datetime: v5.2.2
  • Browser and OS versions: Chrome Version 117.0.5938.149 + macOs Ventura 13.5.2

Question

Hi, we are using the TimePicker component. We want to show the time in UTC, but it is not possible (without doing some hacky transformation) because internally, the component uses these functions: getHours, getMinutes, getSeconds. All of them are representations using the local time.

For example, we have this: "2023-09-09T09:43:06.206Z", and we want to represent the UTC time, but it is impossible because TimePicker will always show the local time representation.

I would like to ask two things:

  1. Is this correct? Or am I missing something?
  2. I have seen that the date time package is being improved to support local times. Is TimePicker going to be improved with this functionality?

Thank you very much!

Our hack Using the functions available in timeZoneUtils, we managed to transform the date like this:

const dateToTransform = "2023-09-09T09:43:06.206Z"
const transformedDate = TimezoneUtils.convertLocalDateToTimezoneTime(
    new Date(dateToTransform),
    "Etc/UTC
);

console.log(transformedDate.toISOString()); // "2023-09-09T07:43:06.206Z" 

We also needed to transform it with convertDateToLocalEquivalentOfTimezoneTime in the onChange method.

Guide contributeur