Skip to content

Commit

Permalink
Simplify check and add link
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed May 8, 2024
1 parent d40bd3c commit ae2e831
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/db/src/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ export function hasPrimaryKey(column: DBColumn) {
return 'primaryKey' in column.schema && !!column.schema.primaryKey;
}

function isISODateString(str: string) {
if (!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(str)) return false;
const d = new Date(str);
return d instanceof Date && !isNaN(d.getTime()) && d.toISOString() === str; // valid date
}
// Taken from:
// https://stackoverflow.com/questions/52869695/check-if-a-date-string-is-in-iso-and-utc-format
const isISODateString = (str: string) =>
/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(str);

const dateType = customType<{ data: Date; driverData: string }>({
dataType() {
Expand Down

0 comments on commit ae2e831

Please sign in to comment.