mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
Change endpoint from persons to people
This commit is contained in:
116
backend/apis/nodejs/node_modules/postgres-date/index.js
generated
vendored
Normal file
116
backend/apis/nodejs/node_modules/postgres-date/index.js
generated
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
'use strict'
|
||||
|
||||
var DATE_TIME = /(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/
|
||||
var DATE = /^(\d{1,})-(\d{2})-(\d{2})( BC)?$/
|
||||
var TIME_ZONE = /([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/
|
||||
var INFINITY = /^-?infinity$/
|
||||
|
||||
module.exports = function parseDate (isoDate) {
|
||||
if (INFINITY.test(isoDate)) {
|
||||
// Capitalize to Infinity before passing to Number
|
||||
return Number(isoDate.replace('i', 'I'))
|
||||
}
|
||||
var matches = DATE_TIME.exec(isoDate)
|
||||
|
||||
if (!matches) {
|
||||
// Force YYYY-MM-DD dates to be parsed as local time
|
||||
return getDate(isoDate) || null
|
||||
}
|
||||
|
||||
var isBC = !!matches[8]
|
||||
var year = parseInt(matches[1], 10)
|
||||
if (isBC) {
|
||||
year = bcYearToNegativeYear(year)
|
||||
}
|
||||
|
||||
var month = parseInt(matches[2], 10) - 1
|
||||
var day = matches[3]
|
||||
var hour = parseInt(matches[4], 10)
|
||||
var minute = parseInt(matches[5], 10)
|
||||
var second = parseInt(matches[6], 10)
|
||||
|
||||
var ms = matches[7]
|
||||
ms = ms ? 1000 * parseFloat(ms) : 0
|
||||
|
||||
var date
|
||||
var offset = timeZoneOffset(isoDate)
|
||||
if (offset != null) {
|
||||
date = new Date(Date.UTC(year, month, day, hour, minute, second, ms))
|
||||
|
||||
// Account for years from 0 to 99 being interpreted as 1900-1999
|
||||
// by Date.UTC / the multi-argument form of the Date constructor
|
||||
if (is0To99(year)) {
|
||||
date.setUTCFullYear(year)
|
||||
}
|
||||
|
||||
if (offset !== 0) {
|
||||
date.setTime(date.getTime() - offset)
|
||||
}
|
||||
} else {
|
||||
date = new Date(year, month, day, hour, minute, second, ms)
|
||||
|
||||
if (is0To99(year)) {
|
||||
date.setFullYear(year)
|
||||
}
|
||||
}
|
||||
|
||||
return date
|
||||
}
|
||||
|
||||
function getDate (isoDate) {
|
||||
var matches = DATE.exec(isoDate)
|
||||
if (!matches) {
|
||||
return
|
||||
}
|
||||
|
||||
var year = parseInt(matches[1], 10)
|
||||
var isBC = !!matches[4]
|
||||
if (isBC) {
|
||||
year = bcYearToNegativeYear(year)
|
||||
}
|
||||
|
||||
var month = parseInt(matches[2], 10) - 1
|
||||
var day = matches[3]
|
||||
// YYYY-MM-DD will be parsed as local time
|
||||
var date = new Date(year, month, day)
|
||||
|
||||
if (is0To99(year)) {
|
||||
date.setFullYear(year)
|
||||
}
|
||||
|
||||
return date
|
||||
}
|
||||
|
||||
// match timezones:
|
||||
// Z (UTC)
|
||||
// -05
|
||||
// +06:30
|
||||
function timeZoneOffset (isoDate) {
|
||||
if (isoDate.endsWith('+00')) {
|
||||
return 0
|
||||
}
|
||||
|
||||
var zone = TIME_ZONE.exec(isoDate.split(' ')[1])
|
||||
if (!zone) return
|
||||
var type = zone[1]
|
||||
|
||||
if (type === 'Z') {
|
||||
return 0
|
||||
}
|
||||
var sign = type === '-' ? -1 : 1
|
||||
var offset = parseInt(zone[2], 10) * 3600 +
|
||||
parseInt(zone[3] || 0, 10) * 60 +
|
||||
parseInt(zone[4] || 0, 10)
|
||||
|
||||
return offset * sign * 1000
|
||||
}
|
||||
|
||||
function bcYearToNegativeYear (year) {
|
||||
// Account for numerical difference between representations of BC years
|
||||
// See: https://github.com/bendrucker/postgres-date/issues/5
|
||||
return -(year - 1)
|
||||
}
|
||||
|
||||
function is0To99 (num) {
|
||||
return num >= 0 && num < 100
|
||||
}
|
21
backend/apis/nodejs/node_modules/postgres-date/license
generated
vendored
Normal file
21
backend/apis/nodejs/node_modules/postgres-date/license
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Ben Drucker <bvdrucker@gmail.com> (bendrucker.me)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
33
backend/apis/nodejs/node_modules/postgres-date/package.json
generated
vendored
Normal file
33
backend/apis/nodejs/node_modules/postgres-date/package.json
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "postgres-date",
|
||||
"main": "index.js",
|
||||
"version": "1.0.7",
|
||||
"description": "Postgres date column parser",
|
||||
"license": "MIT",
|
||||
"repository": "bendrucker/postgres-date",
|
||||
"author": {
|
||||
"name": "Ben Drucker",
|
||||
"email": "bvdrucker@gmail.com",
|
||||
"url": "bendrucker.me"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && tape test.js"
|
||||
},
|
||||
"keywords": [
|
||||
"postgres",
|
||||
"date",
|
||||
"parser"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"standard": "^14.0.0",
|
||||
"tape": "^5.0.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"readme.md"
|
||||
]
|
||||
}
|
49
backend/apis/nodejs/node_modules/postgres-date/readme.md
generated
vendored
Normal file
49
backend/apis/nodejs/node_modules/postgres-date/readme.md
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
# postgres-date [](https://travis-ci.org/bendrucker/postgres-date) [](https://greenkeeper.io/)
|
||||
|
||||
> Postgres date output parser
|
||||
|
||||
This package parses [date/time outputs](https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT) from Postgres into Javascript `Date` objects. Its goal is to match Postgres behavior and preserve data accuracy.
|
||||
|
||||
If you find a case where a valid Postgres output results in incorrect parsing (including loss of precision), please [create a pull request](https://github.com/bendrucker/postgres-date/compare) and provide a failing test.
|
||||
|
||||
**Supported Postgres Versions:** `>= 9.6`
|
||||
|
||||
All prior versions of Postgres are likely compatible but not officially supported.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save postgres-date
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var parse = require('postgres-date')
|
||||
parse('2011-01-23 22:15:51Z')
|
||||
// => 2011-01-23T22:15:51.000Z
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
#### `parse(isoDate)` -> `date`
|
||||
|
||||
##### isoDate
|
||||
|
||||
*Required*
|
||||
Type: `string`
|
||||
|
||||
A date string from Postgres.
|
||||
|
||||
## Releases
|
||||
|
||||
The following semantic versioning increments will be used for changes:
|
||||
|
||||
* **Major**: Removal of support for Node.js versions or Postgres versions (not expected)
|
||||
* **Minor**: Unused, since Postgres returns dates in standard ISO 8601 format
|
||||
* **Patch**: Any fix for parsing behavior
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Ben Drucker](http://bendrucker.me)
|
Reference in New Issue
Block a user