forked from bendrucker/postgres-interval
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
54 lines (49 loc) · 1.22 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* A parsed Postgres interval string.
*/
declare class PostgresInterval {
years: number
months: number
days: number
hours: number
minutes: number
seconds: number
milliseconds: number
/**
* Returns an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Durations)
* compliant string, for example P0Y0M0DT0H9M0S.
*
* ```js
* import { parse } from 'postgres-interval'
* const 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
* import { parse } from 'postgres-interval'
* const interval = parse('01:02:03')
* // => { hours: 1, minutes: 2, seconds: 3 }
* interval.toISOStringShort()
* // PT1H2M3S
* ```
*/
toISOStringShort(): string
}
export function parse(raw: string | IntervalParts): PostgresInterval
export interface IntervalParts {
years?: number
months?: number
days?: number
hours?: number
minutes?: number
seconds?: number
milliseconds?: number
}
export default PostgresInterval