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

Added TimeZoneName in JSON return Object in TimeZone #1162

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions client/packages/lowcoder/src/comps/comps/dateComp/dateComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,16 @@ export const dateRangeControl = (function () {
.build();
})();

const getTimeZoneInfo = (timeZone: any, othereTimeZone: any) => {
const tz = timeZone === 'UserChoice' ? othereTimeZone : timeZone ;
return {
TimeZone: tz,
Offset: dayjs().tz(tz).format('Z') // Get the UTC offset for the selected timezone
};
};
const getTimeZoneInfo = (timeZone: any, otherTimeZone: any) => {
const tz = timeZone === 'UserChoice' ? otherTimeZone : timeZone;

const dateInTz = dayjs().tz(tz);
const offset = dateInTz.format('Z');
const timeZoneName = new Intl.DateTimeFormat('en-US', { timeZone: tz, timeZoneName: 'short' })
.formatToParts().find(part => part.type === 'timeZoneName')?.value;

return { TimeZone: tz, Offset: offset, Name: timeZoneName };
};

export const DatePickerComp = withExposingConfigs(datePickerControl, [
depsConfig({
Expand Down
17 changes: 10 additions & 7 deletions client/packages/lowcoder/src/comps/comps/dateComp/timeComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,16 @@ export const timeRangeControl = (function () {
.build();
})();

const getTimeZoneInfo = (timeZone: any, othereTimeZone: any) => {
const tz = timeZone === 'UserChoice' ? othereTimeZone : timeZone ;
return {
TimeZone: tz,
Offset: dayjs().tz(tz).format('Z') // Get the UTC offset for the selected timezone
};
};
const getTimeZoneInfo = (timeZone: any, otherTimeZone: any) => {
const tz = timeZone === 'UserChoice' ? otherTimeZone : timeZone;

const dateInTz = dayjs().tz(tz);
const offset = dateInTz.format('Z');
const timeZoneName = new Intl.DateTimeFormat('en-US', { timeZone: tz, timeZoneName: 'short' })
.formatToParts().find(part => part.type === 'timeZoneName')?.value;

return { TimeZone: tz, Offset: offset, Name: timeZoneName };
};

export const TimePickerComp = withExposingConfigs(timePickerControl, [
new NameConfig("value", trans("export.timePickerValueDesc")),
Expand Down
Loading