Merge branch 'master' into BUDI-8279/prevent-changing-date-or-time-only-when-fetched
This commit is contained in:
commit
c7a4179c40
|
@ -168,7 +168,11 @@ export const stringifyDate = (
|
||||||
// Ensure we use the correct offset for the date
|
// Ensure we use the correct offset for the date
|
||||||
const referenceDate = value.toDate()
|
const referenceDate = value.toDate()
|
||||||
const offset = referenceDate.getTimezoneOffset() * 60000
|
const offset = referenceDate.getTimezoneOffset() * 60000
|
||||||
return new Date(value.valueOf() - offset).toISOString().slice(0, -1)
|
const date = new Date(value.valueOf() - offset)
|
||||||
|
if (timeOnly) {
|
||||||
|
return date.toISOString().slice(11, 19)
|
||||||
|
}
|
||||||
|
return date.toISOString().slice(0, -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// For date-only fields, construct a manual timestamp string without a time
|
// For date-only fields, construct a manual timestamp string without a time
|
||||||
|
|
|
@ -205,6 +205,10 @@ export async function validate({
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
errors[fieldName] = [`Contains invalid JSON`]
|
errors[fieldName] = [`Contains invalid JSON`]
|
||||||
}
|
}
|
||||||
|
} else if (type === FieldType.DATETIME && column.timeOnly) {
|
||||||
|
if (row[fieldName] && !row[fieldName].match(/^(\d+)(:[0-5]\d){1,2}$/)) {
|
||||||
|
errors[fieldName] = [`${fieldName} is not a valid time`]
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
res = validateJs.single(row[fieldName], constraints)
|
res = validateJs.single(row[fieldName], constraints)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue