mirror of
https://github.com/frappe/books.git
synced 2025-01-04 23:55:24 +00:00
fix: use luxon for Date to and from string
This commit is contained in:
parent
746342e956
commit
1266337f1a
@ -184,11 +184,11 @@ function toDocDate(value: RawValue, field: Field) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value !== 'number' && typeof value !== 'string') {
|
if (typeof value !== 'string') {
|
||||||
throwError(value, field, 'doc');
|
throwError(value, field, 'doc');
|
||||||
}
|
}
|
||||||
|
|
||||||
const date = new Date(value);
|
const date = DateTime.fromISO(value).toJSDate();
|
||||||
if (date.toString() === 'Invalid Date') {
|
if (date.toString() === 'Invalid Date') {
|
||||||
throwError(value, field, 'doc');
|
throwError(value, field, 'doc');
|
||||||
}
|
}
|
||||||
@ -353,14 +353,14 @@ function toRawDate(value: DocValue, field: Field): string | null {
|
|||||||
value = new Date(value);
|
value = new Date(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value instanceof DateTime) {
|
|
||||||
return value.toISODate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Date) {
|
if (value instanceof Date) {
|
||||||
return DateTime.fromJSDate(value).toISODate();
|
return DateTime.fromJSDate(value).toISODate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value instanceof DateTime) {
|
||||||
|
return value.toISODate();
|
||||||
|
}
|
||||||
|
|
||||||
throwError(value, field, 'raw');
|
throwError(value, field, 'raw');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
this.showInput = false;
|
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())) {
|
if (Number.isNaN(value.valueOf())) {
|
||||||
value = null;
|
value = null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user