MCPcopy Create free account
hub / github.com/Effect-TS/effect / dateDays

Function dateDays

packages/sql/pg/src/PgTypes.ts:1186–1195  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

1184
1185/** Days since the PostgreSQL epoch, or an infinity sentinel. */
1186const dateDays = (value: unknown): number => {
1187 const text = requireString(value, "date")
1188 if (text === "infinity") return INT32_MAX
1189 if (text === "-infinity") return INT32_MIN
1190 const days = parseDate(text) - PG_EPOCH_DAYS
1191 if (days <= INT32_MIN || days >= INT32_MAX) {
1192 return fail(`date out of range: "${text}"`)
1193 }
1194 return days
1195}
1196
1197const dateCodec: UnsafeCodec<any> = codecOf(
1198 (bytes, offset, size) => {

Callers 1

PgTypes.tsFile · 0.85

Calls 3

requireStringFunction · 0.85
parseDateFunction · 0.70
failFunction · 0.70

Tested by

no test coverage detected