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

@abcnews/fuzzy-dates

Package Overview
Dependencies
Maintainers
7
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abcnews/fuzzy-dates - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

29

lib/index.js

@@ -7,3 +7,4 @@ 'use strict';

var MONTHS = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'nov', 'dec'];
var MONTHS = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
var FULL_MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];

@@ -185,2 +186,26 @@ /**

module.exports = { parse: parse, compare: compare };
/**
* Output a date (optionally fuzzy) as something like February 10, 2017 or Mid February, 2017
* @param {Date} date
* @return {string}
*/
function formatDate(date) {
var tokens = [];
// Early, Mid, or Late
if (typeof date.fuzzy === 'string') {
tokens.push(date.fuzzy.charAt(0).toUpperCase() + date.fuzzy.slice(1));
}
// Month
tokens.push(FULL_MONTHS[date.getMonth()]);
// Day number
if (!date.fuzzy) {
tokens.push(date.getDate());
}
return tokens.join(' ') + ', ' + date.getFullYear();
}
module.exports = { parse: parse, compare: compare, formatDate: formatDate };

7

package.json
{
"name": "@abcnews/fuzzy-dates",
"version": "1.0.0",
"version": "1.1.0",
"description": "A fuzzy date parser/sorter",

@@ -15,3 +15,6 @@ "main": "lib/index.js",

},
"keywords": ["fuzzy", "dates"],
"keywords": [
"fuzzy",
"dates"
],
"author": "Nathan Hoad",

@@ -18,0 +21,0 @@ "license": "ISC",

@@ -65,4 +65,16 @@ # Fuzzy Dates

You can also output a date in a nice and simple format
```javascript
const FuzzyDates = require('@abcnews/fuzzy-dates');
let date = FuzzyDates.parse('10 March 2015');
FuzzyDates.formatDate(date); // March 10, 2015
date = FuzzyDates.parse('2017, Late November');
FuzzyDates.formatDate(date); // Late November, 2017
```
## Authors
- Nathan Hoad ([nathan@nathanhoad.net](mailto:nathan@nathanhoad.net))
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