Registry / database / zol-datetime

zol-datetime

JSON →
library0.5.1jsnpmunverified

SQL Date/Time functionality for Zol, a TypeScript ORM for PostgreSQL. Current stable version is 0.5.1. Provides types and utilities to handle date and time operations in SQL queries, with seamless integration into Zol's query builder. Ships TypeScript declarations. Useful for PostgreSQL-specific date/time functions, ISO strings, and intervals.

npm install zol-datetime
INSTALL
IMPORT
SIG · ZOL-DATETIME
Z
zol-datetime
databasejavascriptv0.5.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

LocalDate
import { LocalDate } from 'zol-datetime'
import { LocalDate } from 'js-joda'
Use the re-exported wrapper from zol-datetime for compatibility with Zol types rather than raw js-joda.
LocalDateTime
import { LocalDateTime } from 'zol-datetime'
Available as named export from package root.
Instant
import { Instant } from 'zol-datetime'
Instant is re-exported with Zol-specific serialization.

Demonstrates creating a LocalDate and using it in a Zol template literal to generate a parameterized SQL query.

import { LocalDate } from 'zol-datetime'; import { zol } from 'zol'; const date = LocalDate.parse('2023-12-25'); const query = zol`SELECT * FROM events WHERE date = ${date}`; console.log(query.sql); // SELECT * FROM events WHERE date = $1 console.log(query.params); // ['2023-12-25']
Debug
Known issues
breakingVersion 0.5.x changed the serialization format for LocalDate to ISO string (yyyy-mm-dd) instead of a custom format.
fix
Upgrade SQL column types and ensure database expects ISO format.
affects: >=0.5.0
breakingThe default import `ZolDatetime` was removed in 0.5.0; use named imports instead.
fix
Replace `import ZolDatetime from 'zol-datetime'` with `import { LocalDate, LocalDateTime, ... } from 'zol-datetime'`.
affects: >=0.5.0
gotchaYou cannot use JavaScript native Date objects directly in Zol queries; you must wrap them with zol-datetime types.
fix
Convert native Date to LocalDate: `const localDate = LocalDate.ofInstant(date.toInstant())`.
affects: *
deprecatedThe `LocalDate.parse` function accepts a string in ISO format only; non-ISO strings (e.g., '01/01/2020') will throw an error.
fix
Ensure all date strings conform to ISO 8601 before passing to parse.
affects: *
Errors
Common errors & fixes
Error: No local function: LocalDate
Importing from wrong package or incorrect symbol name.
fix
Use `import { LocalDate } from 'zol-datetime'` instead of `require('js-joda').LocalDate`.
TypeError: DateTimeFormat is not a constructor
Trying to use `DateTimeFormat` from `zol-datetime` which does not exist.
fix
Use `LocalDate`, `LocalDateTime`, or `Instant` from `zol-datetime`.
Error: Invalid format: "2020-01-01T00:00:00"
Passing a full timestamp string into LocalDate.parse, which expects only date part.
fix
Use `LocalDateTime.parse` for full datetime strings, or truncate to date part.
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies
js-jodarequiredCore date/time library used for types and parsing
zolrequiredPeer dependency, provides query builder and SQL generation infrastructure
Agent activity
40 hits · last 30 days
node
36
OpenAI (training)
1
Resources
zol-datetime — npm install zol-datetime · libregistry