Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
postgres-date
Advanced tools
Package description
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.
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"
Moment is a widely used package for parsing, validating, manipulating, and formatting dates. It supports multiple date formats and locales. Compared to postgres-date, Moment offers a broader range of functionalities beyond just parsing PostgreSQL date strings, including operations on dates and extensive formatting options.
date-fns is a modern JavaScript date utility library offering a comprehensive set of date manipulation functions. It provides functions for parsing, formatting, and manipulating dates. Unlike postgres-date, which is focused on PostgreSQL date strings, date-fns offers a wide array of utilities that can be used with various date formats and is designed with a modular approach.
Luxon is a powerful library for dealing with dates and times in JavaScript. It offers capabilities for parsing, formatting, manipulating, and querying dates and times. Luxon is built on the Intl API and provides time zone support. While postgres-date is specialized for PostgreSQL date strings, Luxon provides a more comprehensive solution for date and time handling, including support for internationalization.
Readme
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.
npm install --save postgres-date
const parse = require('postgres-date')
parse('2011-01-23 22:15:51Z')
// => 2011-01-23T22:15:51.000Z
parse(isoDate)
-> date
Required
Type: string
A date string from Postgres.
The following semantic versioning increments will be used for changes:
MIT © Ben Drucker
FAQs
Postgres date column parser
The npm package postgres-date receives a total of 6,044,770 weekly downloads. As such, postgres-date popularity was classified as popular.
We found that postgres-date demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.