Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dayjs-parser

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dayjs-parser - npm Package Compare versions

Comparing version 0.9.3 to 1.0.0

dist/index.cjs

2

LICENSE.md
ISC License (ISC)
Copyright 2021 Ken Snyder
Copyright 2021-2024 Ken Snyder

@@ -5,0 +5,0 @@ Permission to use, copy, modify, and/or distribute this software for any purpose

{
"name": "dayjs-parser",
"version": "0.9.3",
"description": "Date parsing plugin for dayjs",
"keywords": [
"dayjs",
"date",
"datetime",
"parse",
"parser",
"date parser",
"parse date",
"human"
],
"main": "index.js",
"scripts": {
"test": "sh ./test/run-jest.sh",
"watch": "sh ./test/run-jest.sh --watch",
"coverage": "sh ./test/run-jest.sh --coverage"
},
"repository": {
"type": "git",
"url": "git+https://github.com/kensnyder/dayjs-parser.git"
},
"author": {
"name": "Ken Snyder",
"email": "kendsnyder@gmail.com"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/kensnyder/dayjs-parser/issues"
},
"homepage": "https://github.com/kensnyder/dayjs-parser#readme",
"dependencies": {
"any-date-parser": "1.5.2"
},
"peerDependencies": {
"dayjs": "1.10.4"
},
"devDependencies": {
"eslint": "8.8.0",
"jest": "27.5.0",
"prettier": "2.5.1"
}
"name": "dayjs-parser",
"version": "1.0.0",
"description": "Date parsing plugin for dayjs",
"keywords": [
"dayjs",
"date",
"datetime",
"parse",
"parser",
"date parser",
"parse date",
"human"
],
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
}
},
"files": [
"dist",
"README.md",
"LICENSE.md"
],
"scripts": {
"test": "./scripts/test.sh run",
"test-watch": "./scripts/test.sh",
"build": "npm run build:clean && npm run build:dts && npm run build:esm && npm run build:cjs",
"build:clean": "rimraf dist/ && mkdir dist",
"build:dts": "yes | npx dts-bundle-generator -o dist/index.d.ts src/plugin.ts",
"build:esm": "yes | npx esbuild src/plugin.ts --bundle --external:any-date-parser --platform=node --format=esm --outfile=dist/index.mjs",
"build:cjs": "yes | npx esbuild src/plugin.ts --bundle --external:any-date-parser --platform=node --format=cjs --outfile=dist/index.cjs",
"coverage": "./scripts/test.sh run --coverage",
"view-coverage": "open ./coverage/lcov-report/index.html"
},
"repository": {
"type": "git",
"url": "git+https://github.com/kensnyder/dayjs-parser.git"
},
"author": {
"name": "Ken Snyder",
"email": "kendsnyder@gmail.com"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/kensnyder/dayjs-parser/issues"
},
"homepage": "https://github.com/kensnyder/dayjs-parser#readme",
"dependencies": {
"any-date-parser": "2.0.0"
},
"peerDependencies": {
"dayjs": "1.11.13"
},
"devDependencies": {
"@types/node": "22.5.5",
"@vitest/coverage-v8": "2.1.1",
"dayjs": "1.11.13",
"eslint": "8.16.0",
"luxon": "3.5.0",
"prettier": "3.3.3",
"prettier-plugin-organize-imports": "4.0.0",
"rimraf": "6.0.1",
"typescript": "5.6.2",
"vitest": "2.1.1"
}
}
# dayjs-parser
[![NPM Link](https://img.shields.io/npm/v/dayjs-parser?v=0.9.3)](https://npmjs.com/package/dayjs-parser)
[![Build Status](https://ci.appveyor.com/api/projects/status/github/kensnyder/dayjs-parser?branch=master&svg=true&v=0.9.3)](https://ci.appveyor.com/project/kensnyder/dayjs-parser/branch/master)
[![Code Coverage](https://codecov.io/gh/kensnyder/dayjs-parser/branch/master/graph/badge.svg?v=0.9.3)](https://codecov.io/gh/kensnyder/dayjs-parser)
[![ISC License](https://img.shields.io/npm/l/dayjs-parser.svg?v=0.9.3)](https://opensource.org/licenses/ISC)
[![NPM Link](https://img.shields.io/npm/v/dayjs-parser?v=1.0.0)](https://npmjs.com/package/dayjs-parser)
[![Build Status](https://github.com/kensnyder/dayjs-parser/actions/workflows/workflow.yml/badge.svg?v=2.0.0-rc.1)](https://github.com/kensnyder/dayjs-parser/actions)
[![Code Coverage](https://codecov.io/gh/kensnyder/dayjs-parser/branch/main/graph/badge.svg?v=2.0.0-rc.1)](https://codecov.io/gh/kensnyder/dayjs-parser)
[![Language: TypeScript](https://badgen.net/static/language/TS?v=1.0.0)](https://github.com/search?q=repo:kensnyder/dayjs-parser++language:TypeScript&type=code)
![Tree shakeable](https://badgen.net/static/tree%20shakeable/yes/green?v=1.0.0)
[![ISC License](https://badgen.net/github/license/kensnyder/dayjs-parser?v=1.0.0)](https://opensource.org/licenses/ISC)
A comprehensive and extensible date parsing plugin for
[dayjs](https://day.js.org). It allows passing a wide variety of date formats to
`dayjs()`. Most locales are supported automatically.
The most comprehensive and accurate date parser for Node and browsers. It uses
`Intl` to provide parsing support for all installed locales. This plugin
connects the capabilities of
[any-date-parser](https://npmjs.com/package/dany-date-parser) to
[dayjs](https://day.js.org).
It uses [any-date-parser](https://npmjs.com/package/any-date-parser) for parsing
date strings.
It allows passing every imaginable date format to the `dayjs()` function. Most
locales are supported automatically.

@@ -20,4 +24,4 @@ ## Table of Contents

- [Usage](#usage)
- [Recognized Formats](#recognized-formats)
- [Adding Custom Formats](#adding-custom-formats)
- [Breaking changes](#breaking-changes-v0x--v1x)
- [Recognized Formats](http://npmjs.com/packages/dayjs-parser#recognized-formats)
- [Locale Support](#locale-support)

@@ -27,2 +31,4 @@ - [Sister Packages](#sister-packages)

- [Contributing](#contributing)
- [ISC License](./LICENSE.md)
- [Changelog](./CHANGELOG.md)

@@ -45,18 +51,8 @@ ## Motivation

OPTION 1: Use a single import
Register as a regular dayjs plugin
```js
const dayjs = require('dayjs-parser/dayjs');
import dayjs from 'dayjs';
import dayjsParser from 'dayjs-parser';
const date1 = dayjs('March 5th, 2016 at 7:05pm');
const date2 = dayjs('9 days ago');
const date3 = dayjs('2016-03-05 23:59:59 CST');
```
OPTION 2: Register as a regular dayjs plugin
```js
const dayjs = require('dayjs');
const parserPlugin = require('dayjs-parser');
dayjs.extend(parserPlugin);

@@ -69,45 +65,7 @@

## Recognized Formats
## Breaking changes v0.x => v1.x
- 24 hour time
- 12 hour time
- timezone offsets
- timezone abbreviations
- year month day
- year monthname day
- month day year
- monthname day year
- day month year
- day monthname year
- +/-/ago periods
- now/today/yesterday/tomorrow
- Twitter
Dropped support for importing from `dayjs-parser/dayjs`. Now you must register
dayjsParser as a plugin. Both cjs and esm now supported.
`dayjs-parser` relies on
[any-date-format](https://www.npmjs.com/package/any-date-parser) which supports
even more formats. See the
[exhaustive list](https://www.npmjs.com/package/any-date-parser#exhaustive-list-of-date-formats).
## Adding Custom Formats
See
[any-date-format's instructions](https://www.npmjs.com/package/any-date-parser#adding-custom-formats).
Example:
```js
const parser = require('dayjs-parser');
parser.addFormat(
new parser.Format({
matcher: /^Q([1-4]) (\d{4})$/,
handler: function ([, quarter, year]) {
const monthByQuarter = { 1: 1, 2: 4, 3: 7, 4: 10 };
const month = monthByQuarter[quarter];
return { year, month };
},
})
);
```
## Locale Support

@@ -118,3 +76,5 @@

```js
const parserPlugin = require('dayjs-parser');
import dayjs from 'dayjs';
import dayjsParser from 'dayjs-parser';
dayjs.extend(parserPlugin);

@@ -126,2 +86,4 @@ dayjs.locale('fr');

Note that your system must have that locale installed.
See the [Dayjs docs on locales](https://day.js.org/docs/en/i18n/i18n)

@@ -132,3 +94,3 @@

- Standalone Parser:
[any-date-format](http://npmjs.com/packages/any-date-format)
[dayjs-parser](http://npmjs.com/packages/dayjs-parser)
- Luxon: [luxon-parser](http://npmjs.com/package/luxon-parser)

@@ -135,0 +97,0 @@ - Moment: [moment-parseplus](http://npmjs.com/package/moment-parseplus)

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc