mirror of
https://github.com/frappe/books.git
synced 2025-01-02 22:50:14 +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;
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user