Socket
Socket
Sign inDemoInstall

postgres-date

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postgres-date

Postgres date column parser


Version published
Weekly downloads
6.3M
increased by2.23%
Maintainers
1
Install size
10.6 kB
Created
Weekly downloads
 

Package description

What is postgres-date?

The postgres-date npm package is designed to parse and handle dates in PostgreSQL format. It provides functionalities for converting PostgreSQL date and timestamp strings into JavaScript Date objects. This can be particularly useful when working with PostgreSQL databases in Node.js applications, ensuring that date and timestamp data is correctly handled and manipulated.

What are postgres-date's main functionalities?

Parsing PostgreSQL date strings

This feature allows the conversion of PostgreSQL date strings into JavaScript Date objects. It's useful for handling date information retrieved from a PostgreSQL database.

"const parseDate = require('postgres-date');
const dateString = '2023-04-01';
const dateObject = parseDate(dateString);
console.log(dateObject); // Outputs a JavaScript Date object for 2023-04-01"

Parsing PostgreSQL timestamp strings

Similar to parsing date strings, this feature enables the parsing of PostgreSQL timestamp strings, including those with time information, into JavaScript Date objects.

"const parseDate = require('postgres-date');
const timestampString = '2023-04-01 12:00:00';
const dateObject = parseDate(timestampString);
console.log(dateObject); // Outputs a JavaScript Date object for 2023-04-01 12:00:00"

Other packages similar to postgres-date

Readme

Source

postgres-date tests

Postgres date output parser

This package parses date/time outputs 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 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

const 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

Keywords

FAQs

Last updated on 08 Dec 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc