mirror of
https://github.com/frappe/books.git
synced 2025-01-05 08:02:15 +00:00
fix: store as local date in ISO format
- datetime is stored in UTC
This commit is contained in:
parent
ccf609cbd7
commit
cc7e8b62df
@ -345,12 +345,23 @@ function toRawFloat(value: DocValue, field: Field): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toRawDate(value: DocValue, field: Field): string | null {
|
function toRawDate(value: DocValue, field: Field): string | null {
|
||||||
const dateTime = toRawDateTime(value, field);
|
if (value === null) {
|
||||||
if (dateTime === null) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dateTime.split('T')[0];
|
if (typeof value === 'string' || typeof value === 'number') {
|
||||||
|
value = new Date(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value instanceof DateTime) {
|
||||||
|
return value.toISODate();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value instanceof Date) {
|
||||||
|
return DateTime.fromJSDate(value).toISODate();
|
||||||
|
}
|
||||||
|
|
||||||
|
throwError(value, field, 'raw');
|
||||||
}
|
}
|
||||||
|
|
||||||
function toRawDateTime(value: DocValue, field: Field): string | null {
|
function toRawDateTime(value: DocValue, field: Field): string | null {
|
||||||
@ -367,7 +378,7 @@ function toRawDateTime(value: DocValue, field: Field): string | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (value instanceof DateTime) {
|
if (value instanceof DateTime) {
|
||||||
return (value as DateTime).toISO();
|
return value.toJSDate().toISOString();
|
||||||
}
|
}
|
||||||
|
|
||||||
throwError(value, field, 'raw');
|
throwError(value, field, 'raw');
|
||||||
|
Loading…
Reference in New Issue
Block a user