Merge branch 'main' into next

This commit is contained in:
nocobase[bot] 2025-03-06 10:16:31 +00:00
commit 9243a1199b
2 changed files with 6 additions and 3 deletions

View File

@ -82,6 +82,8 @@ const handleChangeOnFilter = (value, picker, showTime) => {
return value; return value;
}; };
export const handleDateChangeOnForm = (value, dateOnly, utc, picker, showTime, gmt) => { export const handleDateChangeOnForm = (value, dateOnly, utc, picker, showTime, gmt) => {
// @ts-ignore
const currentTimeZone = dayjs.tz.guess();
const format = showTime ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD'; const format = showTime ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD';
if (!value) { if (!value) {
return value; return value;
@ -97,7 +99,8 @@ export const handleDateChangeOnForm = (value, dateOnly, utc, picker, showTime, g
return dayjs(value).startOf(picker).toISOString(); return dayjs(value).startOf(picker).toISOString();
} }
const formattedDate = dayjs(value).format(format); const formattedDate = dayjs(value).format(format);
return dayjs(formattedDate).toISOString(); // @ts-ignore
return dayjs(formattedDate).tz(currentTimeZone, true).toISOString();
} }
if (showTime) { if (showTime) {
return dayjs(value).format(format); return dayjs(value).format(format);

View File

@ -81,7 +81,7 @@ const toMoment = (val: any, options?: Str2momentOptions) => {
if (!val) { if (!val) {
return; return;
} }
const offset = options.utcOffset !== undefined ? options.utcOffset : -1 * new Date().getTimezoneOffset(); const offset = options.utcOffset;
const { gmt, picker, utc = true } = options; const { gmt, picker, utc = true } = options;
if (dayjs(val).isValid()) { if (dayjs(val).isValid()) {
if (!utc) { if (!utc) {
@ -94,7 +94,7 @@ const toMoment = (val: any, options?: Str2momentOptions) => {
if (gmt) { if (gmt) {
return dayjs(val).utcOffset(0); return dayjs(val).utcOffset(0);
} }
return dayjs(val).utcOffset(offsetFromString(offset)); return offset ? dayjs(val).utcOffset(offsetFromString(offset)) : dayjs(val);
} else { } else {
return convertQuarterToFirstDay(val); return convertQuarterToFirstDay(val);
} }