Skip to content

Commit

Permalink
fix: dates (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt authored Jul 17, 2024
1 parent 7afd1d7 commit ed4b643
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/backend/src/checks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export const CHECK_RUNNERS: CheckRunner[] = [

if (!date || !isValid) return sql`true`

return sql`r.created_at ${postgresOperators(operator)} to_timestamp(${parsed.getTime()}::bigint / 1000)`
return sql`r.created_at ${postgresOperators(operator)} ${parsed}`
},
},
{
Expand Down
9 changes: 3 additions & 6 deletions packages/shared/checks/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ function paramSerializer(param: CheckParam, value: any) {
case "number":
return encode(value)
case "date":
const date = value
const utcTimeStamp = date.getTime() - date.getTimezoneOffset() * 60000

return encode(utcTimeStamp)
return encode(new Date(value.getTime()).toISOString())
default:
return undefined
}
Expand All @@ -46,8 +43,8 @@ function deserializeParamValue(
case "number":
return Number(decodeURIComponent(value))
case "date":
const utcTimestamp = Number(value)
return new Date(utcTimestamp + new Date().getTimezoneOffset() * 60000)
console.log(decodeURIComponent(value))
return new Date(decodeURIComponent(value))
default:
return undefined
}
Expand Down

0 comments on commit ed4b643

Please sign in to comment.