2
0
mirror of https://github.com/frappe/books.git synced 2024-09-19 19:19:02 +00:00

fix: use luxon for Date to and from string

This commit is contained in:
18alantom 2023-07-21 11:12:31 +05:30 committed by Alan
parent 746342e956
commit 4614c38751
2 changed files with 7 additions and 7 deletions

View File

@ -184,11 +184,11 @@ function toDocDate(value: RawValue, field: Field) {
return null;
}
if (typeof value !== 'number' && typeof value !== 'string') {
if (typeof value !== 'string') {
throwError(value, field, 'doc');
}
const date = new Date(value);
const date = DateTime.fromISO(value).toJSDate();
if (date.toString() === 'Invalid Date') {
throwError(value, field, 'doc');
}
@ -353,14 +353,14 @@ function toRawDate(value: DocValue, field: Field): string | null {
value = new Date(value);
}
if (value instanceof DateTime) {
return value.toISODate();
}
if (value instanceof Date) {
return DateTime.fromJSDate(value).toISODate();
}
if (value instanceof DateTime) {
return value.toISODate();
}
throwError(value, field, 'raw');
}

View File

@ -115,7 +115,7 @@ export default defineComponent({
}
this.showInput = false;
let value: Date | null = new Date(target.value);
let value: Date | null = DateTime.fromISO(target.value).toJSDate();
if (Number.isNaN(value.valueOf())) {
value = null;
}