palantir/blueprint

Will TimePicker support locale representations?

Open

#6,450 建立於 2023年10月9日

在 GitHub 查看
 (3 留言) (1 反應) (0 負責人)TypeScript (20,263 star) (2,167 fork)batch import
P2Package: datetimeType: feature requestType: questionhelp wanted

描述

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.

貢獻者指南