declare namespace PostgresInterval { export interface IPostgresInterval { years: number; months: number; days: number; hours: number; minutes: number; seconds: number; milliseconds: number; /** * Returns an interval string. This allows the interval object to be passed into prepared statements. * * ```js * var parse = require('postgres-interval') * var interval = parse('01:02:03') * // => { hours: 1, minutes: 2, seconds: 3 } * interval.toPostgres() * // 1 hour 2 minutes 3 seconds * ``` */ toPostgres(): string; /** * Returns an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Durations) compliant string, for example P0Y0M0DT0H9M0S. * * Also available as {@link toISOString toISOString}. * * ```js * var parse = require('postgres-interval') * var interval = parse('01:02:03') * // => { hours: 1, minutes: 2, seconds: 3 } * interval.toISO() * // P0Y0M0DT1H2M3S * ``` */ toISO(): string; /** * Returns an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Durations) compliant string, for example P0Y0M0DT0H9M0S. * * Also available as {@link toISO toISO} for backwards compatibility. * * ```js * var parse = require('postgres-interval') * var interval = parse('01:02:03') * // => { hours: 1, minutes: 2, seconds: 3 } * interval.toISOString() * // P0Y0M0DT1H2M3S * ``` */ toISOString(): string; /** * Returns an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Durations) compliant string shortened to minimum length, for example `PT9M`. * * ```js * var parse = require('postgres-interval') * var interval = parse('01:02:03') * // => { hours: 1, minutes: 2, seconds: 3 } * interval.toISOStringShort() * // PT1H2M3S * ``` */ toISOStringShort(): string; /** * Returns a [`Temporal.Duration`](https://tc39.es/proposal-temporal/docs/duration.html) representing the interval. * * Requires `globalThis.Temporal` (Node 26+, or a polyfill assigned to the global). Throws otherwise. * * Postgres mixed-sign intervals (e.g. `1 mon -1 days`) throw a `RangeError`, because `Temporal.Duration` requires a single sign across all fields. * * The `Temporal` types are not yet in the default TypeScript lib. For this signature to resolve, your project needs Temporal lib types (the TypeScript lib once available, or `@js-temporal/polyfill` types). * * ```js * var parse = require('postgres-interval') * var interval = parse('01:02:03') * // => { hours: 1, minutes: 2, seconds: 3 } * interval.toTemporalDuration().toString() * // PT1H2M3S * ``` */ toTemporalDuration(): Temporal.Duration; } } /** * Parse Postgres interval columns. * * ```js * var parse = require('postgres-interval') * var interval = parse('01:02:03') * // => { hours: 1, minutes: 2, seconds: 3 } * interval.toPostgres() * // 1 hour 2 minutes 3 seconds * interval.toISOString() * // P0Y0M0DT1H2M3S * interval.toISOStringShort() * // PT1H2M3S * ``` * * @param raw A Postgres interval string. */ declare function PostgresInterval(raw: string): PostgresInterval.IPostgresInterval; export = PostgresInterval;