main
|
Last change
on this file was 62b2964, checked in by Klimentina Efremova <klimentina08642@…>, 2 weeks ago |
|
Project Handcraft Marketplace
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Rev | Line | |
|---|
| [62b2964] | 1 | # postgres-interval [](https://travis-ci.org/bendrucker/postgres-interval) [](https://greenkeeper.io/)
|
|---|
| 2 |
|
|---|
| 3 | > Parse Postgres interval columns
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 | ## Install
|
|---|
| 7 |
|
|---|
| 8 | ```
|
|---|
| 9 | $ npm install --save postgres-interval
|
|---|
| 10 | ```
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | ## Usage
|
|---|
| 14 |
|
|---|
| 15 | ```js
|
|---|
| 16 | var parse = require('postgres-interval')
|
|---|
| 17 | var interval = parse('01:02:03')
|
|---|
| 18 | //=> {hours: 1, minutes: 2, seconds: 3}
|
|---|
| 19 | interval.toPostgres()
|
|---|
| 20 | // 3 seconds 2 minutes 1 hours
|
|---|
| 21 | interval.toISO()
|
|---|
| 22 | // P0Y0M0DT1H2M3S
|
|---|
| 23 | ```
|
|---|
| 24 |
|
|---|
| 25 | ## API
|
|---|
| 26 |
|
|---|
| 27 | #### `parse(pgInterval)` -> `interval`
|
|---|
| 28 |
|
|---|
| 29 | ##### pgInterval
|
|---|
| 30 |
|
|---|
| 31 | *Required*
|
|---|
| 32 | Type: `string`
|
|---|
| 33 |
|
|---|
| 34 | A Postgres interval string.
|
|---|
| 35 |
|
|---|
| 36 | #### `interval.toPostgres()` -> `string`
|
|---|
| 37 |
|
|---|
| 38 | Returns an interval string. This allows the interval object to be passed into prepared statements.
|
|---|
| 39 |
|
|---|
| 40 | #### `interval.toISOString()` -> `string`
|
|---|
| 41 |
|
|---|
| 42 | Returns an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Durations) compliant string.
|
|---|
| 43 |
|
|---|
| 44 | Also available as `interval.toISO()` for backwards compatibility.
|
|---|
| 45 |
|
|---|
| 46 | ## License
|
|---|
| 47 |
|
|---|
| 48 | MIT © [Ben Drucker](http://bendrucker.me)
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.