Registry / database / postgres-date

postgres-date

JSON →
library2.1.0jsnpmunverified

A focused parser that converts PostgreSQL date/time output strings into JavaScript Date objects, preserving precision and matching Postgres behavior. Version 2.1.0 supports Node >=12 and includes TypeScript types. It is maintained as a patch-level library with no minor releases planned, releasing fixes only. Unlike heavier database clients, this is a minimal single-purpose tool for accurate date parsing.

npm install postgres-date
INSTALL
IMPORT
SIG · POSTGRES-DATE
P
postgres-date
databasejavascriptv2.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import parse from 'postgres-date'
const { parse } = require('postgres-date')
The module exports a single default function. Named import will not work.
require (CommonJS)
const parse = require('postgres-date')
const parse = require('postgres-date').default
CommonJS require returns the default export directly; no .default needed.
parse
import parse from 'postgres-date' parse('2011-01-23 22:15:51Z')
import { parse } from 'postgres-date' parse('2011-01-23 22:15:51Z')
The default export is the parse function; named import parse does not exist.

Demonstrates parsing various PostgreSQL date strings including timezone offsets and infinity values.

import parse from 'postgres-date'; const dateString = '2023-12-25 10:30:00+02'; const date = parse(dateString); console.log(date.toISOString()); // => 2023-12-25T08:30:00.000Z // With time zone offset const date2 = parse('2023-01-01 00:00:00-05'); console.log(date2.toISOString()); // => 2023-01-01T05:00:00.000Z // Infinity dates console.log(parse('infinity')); // null console.log(parse('-infinity')); // null
Debug
Known issues
gotchaInfinity dates ('infinity', '-infinity') return null instead of a Date object.
fix
Check for null before using the result if your data may contain infinity dates.
affects: >=1.0.0
gotchaThe parser does not handle BC dates (before Christ) correctly.
fix
Manually handle BC dates by adjusting the year: parse('0001-01-01 BC') will not give correct year.
affects: >=1.0.0
gotchaParsing timestamps with time zone '00:00' will interpret as UTC, but Postgres may use different timezone offsets.
fix
Ensure your Postgres session timezone is set to UTC or verify the offset before parsing.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: (intermediate value)(...) is not a function
Using named import `{ parse }` instead of default import.
fix
Use `import parse from 'postgres-date'` or `const parse = require('postgres-date')`.
Cannot find module 'postgres-date' or its corresponding type declarations.
Package not installed or TypeScript cannot resolve types.
fix
Run `npm install postgres-date` and ensure tsconfig.json includes `node_modules` in moduleResolution.
RangeError: Invalid time value
Parsing a date string that is out of JavaScript's Date range (e.g., year 100000).
fix
Check input dates and handle extremely large years manually.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Amazon
1
Resources
postgres-date — npm install postgres-date · libregistry