P2Package: datetimeType: feature requestType: questionhelp wanted
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:
- Is this correct? Or am I missing something?
- I have seen that the date time package is being improved to support local times. Is
TimePickergoing 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.