palantir/blueprint

Will TimePicker support locale representations?

Open

#6450 aperta il 9 ott 2023

Vedi su GitHub
 (3 commenti) (1 reazione) (0 assegnatari)TypeScript (2167 fork)batch import
P2Package: datetimeType: feature requestType: questionhelp wanted

Metriche repository

Star
 (20.263 star)
Metriche merge PR
 (Merge medio 43g 10h) (27 PR mergiate in 30 g)

Descrizione

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.

Guida contributor