fix: incorrect time display for noTimeZone datetime field with showTi… (#5458)
Some checks failed
Build docker image / build-and-push (push) Waiting to run
Build pro image / build-and-push (push) Waiting to run
E2E / Build (push) Waiting to run
E2E / Core and plugins (push) Blocked by required conditions
E2E / plugin-workflow (push) Blocked by required conditions
E2E / plugin-workflow-approval (push) Blocked by required conditions
E2E / plugin-data-source-main (push) Blocked by required conditions
E2E / Comment on PR (push) Blocked by required conditions
NocoBase frontEnd test / frontend-test (18) (push) Waiting to run
NocoBase backend test / sqlite-test (20, false) (push) Has been cancelled
NocoBase backend test / sqlite-test (20, true) (push) Has been cancelled
NocoBase backend test / postgres-test (public, 20, nocobase, false) (push) Has been cancelled
NocoBase backend test / postgres-test (public, 20, nocobase, true) (push) Has been cancelled
NocoBase backend test / postgres-test (public, 20, public, false) (push) Has been cancelled
NocoBase backend test / postgres-test (public, 20, public, true) (push) Has been cancelled
NocoBase backend test / postgres-test (user_schema, 20, nocobase, false) (push) Has been cancelled
NocoBase backend test / postgres-test (user_schema, 20, nocobase, true) (push) Has been cancelled
NocoBase backend test / postgres-test (user_schema, 20, public, false) (push) Has been cancelled
NocoBase backend test / postgres-test (user_schema, 20, public, true) (push) Has been cancelled
NocoBase backend test / mysql-test (20, false) (push) Has been cancelled
NocoBase backend test / mysql-test (20, true) (push) Has been cancelled
NocoBase backend test / mariadb-test (20, false) (push) Has been cancelled
NocoBase backend test / mariadb-test (20, true) (push) Has been cancelled
Test on Windows / build (push) Has been cancelled

* fix: incorrect time display for noTimeZone datetime field with showTime enabled

* fix: test
This commit is contained in:
Katherine 2024-10-18 18:03:21 +08:00 committed by GitHub
parent 2ccfaf4f76
commit 012f648bb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -62,7 +62,7 @@ describe('mapDatePicker', () => {
};
const result = mapDatePicker()(props);
result.onChange(dayjs.utc('2022-02-22 22:22:22'));
expect(props.onChange).toHaveBeenCalledWith('2022-02-22 00:00:00');
expect(props.onChange).toHaveBeenCalledWith('2022-02-22 22:22:22');
});
it('should call onChange with correct value when showTime is true and gmt is false', () => {
@ -74,7 +74,7 @@ describe('mapDatePicker', () => {
const result = mapDatePicker()(props);
const m = dayjs('2022-02-22 22:22:22');
result.onChange(m);
expect(props.onChange).toHaveBeenCalledWith('2022-02-22 00:00:00');
expect(props.onChange).toHaveBeenCalledWith('2022-02-22 22:22:22');
});
it('should call onChange with correct value when showTime is false and gmt is true', () => {
@ -202,7 +202,7 @@ describe('mapDatePicker', () => {
};
const result = mapDatePicker()(props);
result.onChange(dayjs('2022-02-22 22:22:22'));
expect(props.onChange).toHaveBeenCalledWith('2022-02-22 00:00:00');
expect(props.onChange).toHaveBeenCalledWith('2022-02-22 22:22:22');
});
it('should call onChange with correct value when picker is year and utc is false', () => {

View File

@ -100,6 +100,9 @@ const handleChangeOnForm = (value, dateOnly, utc, picker, showTime, gmt) => {
const formattedDate = dayjs(value).format(format);
return dayjs(formattedDate).toISOString();
}
if (showTime) {
return dayjs(value).format(format);
}
return dayjs(value).startOf(picker).format(format);
};