fix(client): fix output time in date-picker in date-only mode (#4778)

This commit is contained in:
Junyi 2024-07-08 23:13:05 +08:00 committed by GitHub
parent 850a1dca64
commit 9ba64ee6f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -76,6 +76,12 @@ describe('moment2str', () => {
expect(str).toBe(dayjs('2023-06-21 10:10:00').toISOString()); expect(str).toBe(dayjs('2023-06-21 10:10:00').toISOString());
}); });
test('gmt not configured', () => {
const d = dayjs('2024-06-30');
const str = moment2str(d);
expect(str).toBe(dayjs('2024-06-30 00:00:00').toISOString());
});
test('with time', () => { test('with time', () => {
const m = dayjs('2023-06-21 10:10:00'); const m = dayjs('2023-06-21 10:10:00');
const str = moment2str(m, { showTime: true }); const str = moment2str(m, { showTime: true });

View File

@ -71,7 +71,7 @@ export const moment2str = (value?: Dayjs | null, options: Moment2strOptions = {}
if (typeof gmt === 'boolean') { if (typeof gmt === 'boolean') {
return gmt ? toGmtByPicker(value, picker) : toLocalByPicker(value, picker); return gmt ? toGmtByPicker(value, picker) : toLocalByPicker(value, picker);
} }
return toGmtByPicker(value, picker); return toLocalByPicker(value, picker);
}; };
export const mapDatePicker = function () { export const mapDatePicker = function () {