Socket
Socket
Sign inDemoInstall

moment-parseplus

Package Overview
Dependencies
1
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.0.3

CHANGELOG.md

8

package.json
{
"name": "moment-parseplus",
"version": "1.0.2",
"version": "1.0.3",
"description": "Date parsing plugin for momentjs",

@@ -35,10 +35,10 @@ "main": "parseplus.js",

"dependencies": {
"moment": ">=2.6.0"
"moment": "^2.6.0"
},
"devDependencies": {
"chai": "^3.5.0",
"istanbul": "^0.4.4",
"istanbul": "^0.4.5",
"mocha": "^2.5.3",
"requirejs": "^2.2.0"
"requirejs": "^2.3.4"
}
}

@@ -137,12 +137,18 @@ (function (root, factory) {

parseplus.updateMatchers = function() {
parseplus.regexes.MONTHNAME = moment.months().join('|') + '|' + moment.monthsShort().join('|');
parseplus.regexes.DAYNAME = moment.weekdays().join('|') + '|' + moment.weekdaysShort().join('|');
var localeData = moment.localeData();
parseplus.regexes.AMPM = localeData._config.meridiemParse.source;
parseplus.regexes.ORDINAL = localeData._config.ordinalParse.source.replace(/.*\(([^)]+)\).*/, '$1');
parseplus.parsers.forEach(function(parser) {
if (parser.template) {
parser.matcher = parseplus.compile(parser.template);
}
});
try {
parseplus.regexes.MONTHNAME = moment.months().join('|') + '|' + moment.monthsShort().join('|');
parseplus.regexes.DAYNAME = moment.weekdays().join('|') + '|' + moment.weekdaysShort().join('|');
var config = moment.localeData()._config;
parseplus.regexes.AMPM = config.meridiemParse.source;
var ordinalParse = config.ordinalParse || config.dayOfMonthOrdinalParse;
parseplus.regexes.ORDINAL = ordinalParse.source.replace(/.*\(([^)]+)\).*/, '$1');
parseplus.parsers.forEach(function (parser) {
if (parser.template) {
parser.matcher = parseplus.compile(parser.template);
}
});
}
catch (e) {
// moment has changed its internal handling of localeData
}
};

@@ -319,4 +325,4 @@

name: 'rfc-2822',
// $1 $2 $3
template: "^(?:(?:_DAYNAME_),? )?(_DAY_)(?:_ORDINAL_)?([ -])(_MONTHNAME_)\\2(_YEAR_)$",
// $1 $2 $3
template: "^(?:(?:_DAYNAME_)\\.?,? )?(_DAY_)(?:_ORDINAL_)?([ -])(_MONTHNAME_)\\.?\\2(_YEAR_)$",
format: 'DD * MMM YYYY'

@@ -327,4 +333,4 @@ })

name: 'rfc-2822-yearless',
// $1 $2
template: "^(?:(?:_DAYNAME_),? )?(_DAY_)(?:_ORDINAL_)?[ -](_MONTHNAME_)$",
// $1 $2
template: "^(?:(?:_DAYNAME_)\\.?,? )?(_DAY_)(?:_ORDINAL_)?[ -](_MONTHNAME_)\\.?$",
handler: function(match) {

@@ -340,4 +346,4 @@ return moment(

name: 'conversational',
// $1 $2 $3
template: "^(?:(?:_DAYNAME_),? )?(_MONTHNAME_) (_DAY_)(?:_ORDINAL_)?,? (_YEAR_)$",
// $1 $2 $3
template: "^(?:(?:_DAYNAME_)\\.?,? )?(_MONTHNAME_)\\.? (_DAY_)(?:_ORDINAL_)?,? (_YEAR_)$",
replacer: '$1 $2 $3',

@@ -349,4 +355,4 @@ format: 'MMM DD YYYY'

name: 'conversational-yearless',
// $1 $2
template: "^(?:(?:_DAYNAME_),? )?(_MONTHNAME_) (_DAY_)(?:_ORDINAL_)?$",
// $1 $2
template: "^(?:(?:_DAYNAME_)\\.?,? )?(_MONTHNAME_)\\.? (_DAY_)(?:_ORDINAL_)?$",
handler: function (match) {

@@ -362,4 +368,4 @@ return moment(

name: 'twitter',
// $1 $2 $3 $4 $5 $6 $7
template: "^(?:_DAYNAME_) (_MONTHNAME_) (_DAY_) (_H24_)?\\:(_MIN_)?(\\:_SEC_)? (_TIMEZONE_) (_YEAR_)$",
// $1 $2 $3 $4 $5 $6 $7
template: "^(?:_DAYNAME_)\\.? (_MONTHNAME_)\\.?\.? (_DAY_) (_H24_)?\\:(_MIN_)?(\\:_SEC_)? (_TIMEZONE_) (_YEAR_)$",
format: 'MMM DD HH mm ss ZZ YYYY'

@@ -622,68 +628,1 @@ })

}));
//
// // RFC-2616
// //
//
// Date.create.patterns = [
//
// // 2 weeks after today, 3 months after 3-5-2008
// [
// 'weeks_months_before_after',
// Date.create.makePattern("^(\\d+) (_UNIT_)s? (before|from|after) (.+)$"),
// function(match) {
// var fromDate = Date.create(match[4]);
// if (fromDate instanceof Date) {
// return fromDate.add((match[3].toLowerCase() == 'before' ? -1 : 1) * match[1], match[2]);
// }
// return false;
// }
// ],
//
//
// // this/next/last january, next thurs
// [
// 'this_next_last',
// Date.create.makePattern("^(this|next|last) (?:(_UNIT_)s?|(_MONTHNAME_)|(_DAYNAME_))$"),
// function(match) {
// // $1 = this/next/last
// var multiplier = match[1].toLowerCase() == 'last' ? -1 : 1;
// var now = Date.current();
// var i;
// var diff;
// var month;
// var weekday;
// // $2 = interval name
// if (match[2]) {
// return now.add(multiplier, match[2]);
// }
// // $3 = month name
// else if (match[3]) {
// month = Date.getMonthByName(match[3]) - 1;
// diff = 12 - (now.getMonth() - month);
// diff = diff > 12 ? diff - 12 : diff;
// return now.add(multiplier * diff, 'month');
// }
// // $4 = weekday name
// else if (match[4]) {
// weekday = Date.getWeekdayByName(match[4]);
// diff = now.getDay() - weekday + 7;
// return now.add(multiplier * (diff == 0 ? 7 : diff), 'day');
// }
// return false;
// }
// ],
//
// // January 4th, July the 4th
// [
// 'conversational_sans_year',
// Date.create.makePattern("^(_MONTHNAME_) (?:the )?(\\d+)(?:st|nd|rd|th)?$"),
// function(match) {
// var d = Date.current();
// if (match[1]) {
// d.setMonth( Date.getMonthByName(match[1]) - 1 );
// }
// d.setDate(match[2]);
// return d;
// }
// ]
// ];
# moment-parseplus
[![Build Status](https://travis-ci.org/kensnyder/moment-parseplus.svg?branch=master&v=1.0.2)](https://travis-ci.org/kensnyder/moment-parseplus)
[![Code Coverage](https://codecov.io/gh/kensnyder/moment-parseplus/branch/master/graph/badge.svg?v=1.0.2)](https://codecov.io/gh/kensnyder/moment-parseplus)
[![MIT License](https://img.shields.io/npm/l/express.svg?v=1.0.2)](https://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.org/kensnyder/moment-parseplus.svg?branch=master&v=1.0.3)](https://travis-ci.org/kensnyder/moment-parseplus)
[![Code Coverage](https://codecov.io/gh/kensnyder/moment-parseplus/branch/master/graph/badge.svg?v=1.0.3)](https://codecov.io/gh/kensnyder/moment-parseplus)
[![MIT License](https://img.shields.io/npm/l/express.svg?v=1.0.3)](https://opensource.org/licenses/MIT)

@@ -11,9 +11,14 @@ An extensible date parsing plugin for [momentjs](http://momentjs.com)

Add support to momentjs for parsing many different date formats with
the ability to easily add new formats.
Add support to momentjs for parsing many different date formats with the ability to easily add new formats.
## Installation and Usage
## Usage
#### Node/CommonJS
Include moment-parseplus and pass a supported date to momentjs.
Use npm to install moment-parseplus and require it. Be sure to require moment sometime before requiring moment-parseplus. Then just pass a supported date string to `moment()`.
```
npm install moment-parseplus --save
```
```js

@@ -26,2 +31,15 @@ var moment = require('moment');

#### Browser
Download and save [parseplus.js](https://raw.githubusercontent.com/kensnyder/moment-parseplus/master/parseplus.js) from GitHub.
Include moment.js and then parseplus.js from the appropriate path. Then just pass a supported date string to `moment()`.
```
<script src="moment.js"></script>
<script src="moment-parseplus.js"></script>
<script>
var date = moment('March 5th, 2016');
</script>
```
## Supported format examples

@@ -66,2 +84,3 @@

- Mar 25 2016
- Mar. 25, 2016
- Mar 25

@@ -68,0 +87,0 @@ - 25 Mar 2016

@@ -21,3 +21,9 @@ var moment = require('moment');

});
it("should parse dates like `Sun, Mar. 14`", function () {
expect(moment('Sun, Mar. 14').format('M D YYYY')).to.equal(march14th);
});
it("should parse dates like `Sun., Mar 14`", function () {
expect(moment('Sun., Mar 14').format('M D YYYY')).to.equal(march14th);
});
});

@@ -22,3 +22,9 @@ var moment = require('moment');

});
it("should parse dates like `Sun, Mar. 4 2012`", function () {
expect(+moment('Sun, Mar. 4 2012')).to.equal(+new Date(2012,2,4));
});
it("should parse dates like `Sun., Mar 4 2012`", function () {
expect(+moment('Sun., Mar 4 2012')).to.equal(+new Date(2012,2,4));
});
});
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