tickbin-parser
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -8,5 +8,5 @@ 'use strict'; | ||
exports.default = function (str, timezoneOffset) { | ||
var patternHour = /(\d*\.{0,1}\d+)\s*(hours|hour|hrs|hr|h)/i; | ||
var patternMin = /(\d*\.{0,1}\d+)\s*(minutes|minute|mins|min|m)/i; | ||
var patternChrono = /(\d*):(\d+)\s*(hours|hour|hrs|hr|h)/i; | ||
var patternHour = /(\d*\.{0,1}\d+)\s*(hours|hour|hrs|hr|h)\b/i; | ||
var patternMin = /(\d*\.{0,1}\d+)\s*(minutes|minute|mins|min|m)\b/i; | ||
var patternChrono = /(\d*):(\d+)\s*(hours|hour|hrs|hr|h)\b/i; | ||
@@ -13,0 +13,0 @@ var hoursMatch = str.match(patternHour); |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
@@ -44,3 +44,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function Entry(user, originalMessage) { | ||
var opts = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var timezoneOffset = arguments[3]; | ||
@@ -47,0 +47,0 @@ |
@@ -23,7 +23,7 @@ 'use strict'; | ||
function NoMeridiemError() { | ||
var message = arguments.length <= 0 || arguments[0] === undefined ? 'No meridiem specified' : arguments[0]; | ||
var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'No meridiem specified'; | ||
_classCallCheck(this, NoMeridiemError); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(NoMeridiemError).call(this, message)); | ||
return _possibleConstructorReturn(this, (NoMeridiemError.__proto__ || Object.getPrototypeOf(NoMeridiemError)).call(this, message)); | ||
} | ||
@@ -30,0 +30,0 @@ |
@@ -11,5 +11,5 @@ 'use strict'; | ||
var _durationParser9 = require('../durationParser'); | ||
var _durationParser32 = require('../durationParser'); | ||
var _durationParser10 = _interopRequireDefault(_durationParser9); | ||
var _durationParser33 = _interopRequireDefault(_durationParser32); | ||
@@ -19,7 +19,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
(0, _tape2.default)('simple hour duration: 5 hours', function (t) { | ||
var _durationParser = (0, _durationParser10.default)('5 hours'); | ||
var _durationParser = (0, _durationParser33.default)('5 hours'), | ||
date = _durationParser.date, | ||
duration = _durationParser.duration; | ||
var date = _durationParser.date; | ||
var duration = _durationParser.duration; | ||
t.ok((0, _moment2.default)().isSame(date, 'day'), 'parsed as current date'); | ||
@@ -32,7 +31,6 @@ t.equal(duration, 18000, 'parsed duration'); // 5 hours in seconds | ||
(0, _tape2.default)('simple minute duration: 30 minutes', function (t) { | ||
var _durationParser2 = (0, _durationParser10.default)('30 minutes'); | ||
var _durationParser2 = (0, _durationParser33.default)('30 minutes'), | ||
date = _durationParser2.date, | ||
duration = _durationParser2.duration; | ||
var date = _durationParser2.date; | ||
var duration = _durationParser2.duration; | ||
t.ok((0, _moment2.default)().isSame(date, 'day'), 'parsed as current date'); | ||
@@ -45,7 +43,6 @@ t.equal(duration, 1800, 'parsed duration'); // 30 minutes in seconds | ||
(0, _tape2.default)('hour and minute duration: 5 hours 30 minutes', function (t) { | ||
var _durationParser3 = (0, _durationParser10.default)('5 hours 30 minutes'); | ||
var _durationParser3 = (0, _durationParser33.default)('5 hours 30 minutes'), | ||
date = _durationParser3.date, | ||
duration = _durationParser3.duration; | ||
var date = _durationParser3.date; | ||
var duration = _durationParser3.duration; | ||
t.ok((0, _moment2.default)().isSame(date, 'day'), 'parsed as current date'); | ||
@@ -58,7 +55,6 @@ t.equal(duration, 19800, 'parsed duration'); // 30 minutes in seconds | ||
(0, _tape2.default)('chrono input: 5:30 hours', function (t) { | ||
var _durationParser4 = (0, _durationParser10.default)('5:30 hours'); | ||
var _durationParser4 = (0, _durationParser33.default)('5:30 hours'), | ||
date = _durationParser4.date, | ||
duration = _durationParser4.duration; | ||
var date = _durationParser4.date; | ||
var duration = _durationParser4.duration; | ||
t.ok((0, _moment2.default)().isSame(date, 'day'), 'parsed as current date'); | ||
@@ -71,7 +67,6 @@ t.equal(duration, 19800, 'parsed duration'); // 30 minutes in seconds | ||
(0, _tape2.default)('implied date: yesterday 5 hours', function (t) { | ||
var _durationParser5 = (0, _durationParser10.default)('yesterday 5 hours'); | ||
var _durationParser5 = (0, _durationParser33.default)('yesterday 5 hours'), | ||
date = _durationParser5.date, | ||
duration = _durationParser5.duration; | ||
var date = _durationParser5.date; | ||
var duration = _durationParser5.duration; | ||
t.ok((0, _moment2.default)().subtract(1, 'day').isSame(date, 'day'), 'parsed as yesterday'); | ||
@@ -84,7 +79,6 @@ t.equal(duration, 18000, 'parsed duration'); // 5 hours in seconds | ||
(0, _tape2.default)('specified date: Aug 15 5 hours', function (t) { | ||
var _durationParser6 = (0, _durationParser10.default)('Aug 15 5 hours'); | ||
var _durationParser6 = (0, _durationParser33.default)('Aug 15 5 hours'), | ||
date = _durationParser6.date, | ||
duration = _durationParser6.duration; | ||
var date = _durationParser6.date; | ||
var duration = _durationParser6.duration; | ||
t.equal((0, _moment2.default)(date).date(), 15, 'date is the 15th day'); | ||
@@ -98,7 +92,6 @@ t.equal((0, _moment2.default)(date).month(), 7, 'date is Aug'); | ||
(0, _tape2.default)('units in decimal: 1.5 hours 1.5 minutes', function (t) { | ||
var _durationParser7 = (0, _durationParser10.default)('1.5 hours 1.5 minutes'); | ||
var _durationParser7 = (0, _durationParser33.default)('1.5 hours 1.5 minutes'), | ||
date = _durationParser7.date, | ||
duration = _durationParser7.duration; | ||
var date = _durationParser7.date; | ||
var duration = _durationParser7.duration; | ||
t.ok((0, _moment2.default)().isSame(date, 'day'), 'parsed as current date'); | ||
@@ -111,9 +104,160 @@ t.equal(duration, 5490, 'parsed duration'); // 1.5 h and 1.5 m in seconds | ||
(0, _tape2.default)('returns original message without date or duration', function (t) { | ||
var _durationParser8 = (0, _durationParser10.default)('yesterday 5 hours all the #things'); | ||
var _durationParser8 = (0, _durationParser33.default)('yesterday 5 hours all the #things'), | ||
message = _durationParser8.message; | ||
var message = _durationParser8.message; | ||
t.equal(message, 'all the #things', 'stripped date and time from message'); | ||
t.end(); | ||
}); | ||
(0, _tape2.default)('does not take the first letter from other words', function (t) { | ||
var _durationParser9 = (0, _durationParser33.default)('2 houses'), | ||
dh = _durationParser9.duration; | ||
t.equal(dh, 0, 'does not take h from \'houses\''); | ||
var _durationParser10 = (0, _durationParser33.default)('2.5 mouses'), | ||
dm = _durationParser10.duration; | ||
t.equal(dm, 0, 'does not take m from \'mouses\''); | ||
var _durationParser11 = (0, _durationParser33.default)('2:30 houses'), | ||
dc = _durationParser11.duration; | ||
t.equal(dc, 0, 'does not take h from \'houses\''); | ||
t.end(); | ||
}); | ||
(0, _tape2.default)('supports various unit formats', function (t) { | ||
t.test('parses minutes', function (t) { | ||
var _durationParser12 = (0, _durationParser33.default)('30 minutes'), | ||
duration = _durationParser12.duration; | ||
t.equal(duration, 1800, 'parsed duration'); | ||
var _durationParser13 = (0, _durationParser33.default)('30minutes'), | ||
duration2 = _durationParser13.duration; | ||
t.equal(duration2, 1800, 'parsed duration'); | ||
t.end(); | ||
}); | ||
t.test('parses minute', function (t) { | ||
var _durationParser14 = (0, _durationParser33.default)('30 minute'), | ||
duration = _durationParser14.duration; | ||
t.equal(duration, 1800, 'parsed duration'); | ||
var _durationParser15 = (0, _durationParser33.default)('30minute'), | ||
duration2 = _durationParser15.duration; | ||
t.equal(duration2, 1800, 'parsed duration'); | ||
t.end(); | ||
}); | ||
t.test('parses mins', function (t) { | ||
var _durationParser16 = (0, _durationParser33.default)('30 mins'), | ||
duration = _durationParser16.duration; | ||
t.equal(duration, 1800, 'parsed duration'); | ||
var _durationParser17 = (0, _durationParser33.default)('30mins'), | ||
duration2 = _durationParser17.duration; | ||
t.equal(duration2, 1800, 'parsed duration'); | ||
t.end(); | ||
}); | ||
t.test('parses min', function (t) { | ||
var _durationParser18 = (0, _durationParser33.default)('30 min'), | ||
duration = _durationParser18.duration; | ||
t.equal(duration, 1800, 'parsed duration'); | ||
var _durationParser19 = (0, _durationParser33.default)('30min'), | ||
duration2 = _durationParser19.duration; | ||
t.equal(duration2, 1800, 'parsed duration'); | ||
t.end(); | ||
}); | ||
t.test('parses m', function (t) { | ||
var _durationParser20 = (0, _durationParser33.default)('30 m'), | ||
duration = _durationParser20.duration; | ||
t.equal(duration, 1800, 'parsed duration'); | ||
var _durationParser21 = (0, _durationParser33.default)('30m'), | ||
duration2 = _durationParser21.duration; | ||
t.equal(duration2, 1800, 'parsed duration'); | ||
t.end(); | ||
}); | ||
t.test('parses hours', function (t) { | ||
var _durationParser22 = (0, _durationParser33.default)('1 hours'), | ||
duration = _durationParser22.duration; | ||
t.equal(duration, 3600, 'parsed duration'); | ||
var _durationParser23 = (0, _durationParser33.default)('1hours'), | ||
duration2 = _durationParser23.duration; | ||
t.equal(duration2, 3600, 'parsed duration'); | ||
t.end(); | ||
}); | ||
t.test('parses hour', function (t) { | ||
var _durationParser24 = (0, _durationParser33.default)('1 hour'), | ||
duration = _durationParser24.duration; | ||
t.equal(duration, 3600, 'parsed duration'); | ||
var _durationParser25 = (0, _durationParser33.default)('1hour'), | ||
duration2 = _durationParser25.duration; | ||
t.equal(duration2, 3600, 'parsed duration'); | ||
t.end(); | ||
}); | ||
t.test('parses hrs', function (t) { | ||
var _durationParser26 = (0, _durationParser33.default)('1 hrs'), | ||
duration = _durationParser26.duration; | ||
t.equal(duration, 3600, 'parsed duration'); | ||
var _durationParser27 = (0, _durationParser33.default)('1hrs'), | ||
duration2 = _durationParser27.duration; | ||
t.equal(duration2, 3600, 'parsed duration'); | ||
t.end(); | ||
}); | ||
t.test('parses hr', function (t) { | ||
var _durationParser28 = (0, _durationParser33.default)('1 hr'), | ||
duration = _durationParser28.duration; | ||
t.equal(duration, 3600, 'parsed duration'); | ||
var _durationParser29 = (0, _durationParser33.default)('1hr'), | ||
duration2 = _durationParser29.duration; | ||
t.equal(duration2, 3600, 'parsed duration'); | ||
t.end(); | ||
}); | ||
t.test('parses h', function (t) { | ||
var _durationParser30 = (0, _durationParser33.default)('1 h'), | ||
duration = _durationParser30.duration; | ||
t.equal(duration, 3600, 'parsed duration'); | ||
var _durationParser31 = (0, _durationParser33.default)('1h'), | ||
duration2 = _durationParser31.duration; | ||
t.equal(duration2, 3600, 'parsed duration'); | ||
t.end(); | ||
}); | ||
t.end(); | ||
}); |
@@ -32,7 +32,6 @@ 'use strict'; | ||
var _e$getDates = e.getDates(); | ||
var _e$getDates = e.getDates(), | ||
start = _e$getDates.start, | ||
end = _e$getDates.end; | ||
var start = _e$getDates.start; | ||
var end = _e$getDates.end; | ||
t.ok(e.hasDates, 'entry has dates'); | ||
@@ -49,7 +48,6 @@ t.equals(e.original, '8am-10am worked on things'); | ||
var _e$getDates2 = e.getDates(); | ||
var _e$getDates2 = e.getDates(), | ||
start = _e$getDates2.start, | ||
end = _e$getDates2.end; | ||
var start = _e$getDates2.start; | ||
var end = _e$getDates2.end; | ||
t.ok(e.hasDates, 'entry has dates'); | ||
@@ -66,7 +64,6 @@ t.equals(e.original, '8am-5pm worked on things'); | ||
var _e$getDates3 = e.getDates(); | ||
var _e$getDates3 = e.getDates(), | ||
start = _e$getDates3.start, | ||
end = _e$getDates3.end; | ||
var start = _e$getDates3.start; | ||
var end = _e$getDates3.end; | ||
t.notOk(e.hasDates, 'flag indicates that no dates are present'); | ||
@@ -84,8 +81,6 @@ t.notOk(start, 'no start date provided'); | ||
var _e$getDates4 = e.getDates(); | ||
var _e$getDates4 = e.getDates(), | ||
start = _e$getDates4.start, | ||
end = _e$getDates4.end; | ||
var start = _e$getDates4.start; | ||
var end = _e$getDates4.end; | ||
t.ok((0, _moment2.default)(start).isSame(date, 'day'), 'start has the same day'); | ||
@@ -102,8 +97,6 @@ t.ok((0, _moment2.default)(end).isSame(date, 'day'), 'end has the same day'); | ||
var _e$getDates5 = e.getDates(); | ||
var _e$getDates5 = e.getDates(), | ||
start = _e$getDates5.start, | ||
end = _e$getDates5.end; | ||
var start = _e$getDates5.start; | ||
var end = _e$getDates5.end; | ||
t.ok((0, _moment2.default)(start).isSame(date, 'day'), 'start date is today'); | ||
@@ -121,8 +114,6 @@ t.ok((0, _moment2.default)(end).isSame(date, 'day'), 'end date is today'); | ||
var _e$getDates6 = e.getDates(); | ||
var _e$getDates6 = e.getDates(), | ||
start = _e$getDates6.start, | ||
end = _e$getDates6.end; | ||
var start = _e$getDates6.start; | ||
var end = _e$getDates6.end; | ||
t.equal((0, _moment2.default)(start).utc().hour(), 16, 'start is 8am in UTC-08:00'); | ||
@@ -342,6 +333,5 @@ t.equal((0, _moment2.default)(end).utc().hour(), 23, 'end is 3pm in UTC-08:00'); | ||
var _e$getDates7 = e.getDates(); | ||
var _e$getDates7 = e.getDates(), | ||
start = _e$getDates7.start; | ||
var start = _e$getDates7.start; | ||
t.equals(e.createdFrom, 'duration', 'created from duration'); | ||
@@ -358,10 +348,31 @@ t.equals(e.original, '4 hours worked on things', 'sets orignal message'); | ||
var _e$getDates8 = e.getDates(); | ||
var _e$getDates8 = e.getDates(), | ||
start = _e$getDates8.start; | ||
var start = _e$getDates8.start; | ||
t.equals((0, _moment2.default)(e.startArr).hour(), 12, 'start is noon in utc'); | ||
t.end(); | ||
}); | ||
t.equals((0, _moment2.default)(e.startArr).hour(), 12, 'start is noon in utc'); | ||
(0, _tape2.default)('entry duration whitespace', function (t) { | ||
var e = void 0; | ||
e = new _entry2.default(userId, '1-2pm ate 4 hotdogs'); | ||
t.equal(e.createdFrom, 'calendar', 'used 1-2pm instead of 4 h'); | ||
e = new _entry2.default(userId, '1-2pm ate 3 mini dougnuts'); | ||
t.equal(e.createdFrom, 'calendar', 'used 1-2pm instead of 3 m'); | ||
try { | ||
e = new _entry2.default(userId, '2:30-3:30 meeting'); | ||
} catch (err) { | ||
t.equal(err.name, 'NoMeridiemError', 'threw error instead of using 30 m'); | ||
} | ||
e = new _entry2.default(userId, '9am-10 Researching SMS online S3 hosting options'); | ||
t.equal(e.createdFrom, 'calendar', 'used 9am-10 instead of 3 h'); | ||
e = new _entry2.default(userId, '1:30-2:45pm 2 month planning meeting'); | ||
t.equal(e.createdFrom, 'calendar', 'used 1:30-2:45pm instead of 2 m'); | ||
t.end(); | ||
}); |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
@@ -20,7 +20,6 @@ var _tape = require('tape'); | ||
(0, _tape2.default)('simple am times: 8am-10am', function (t) { | ||
var _parser = (0, _parser28.default)('8am-10am'); | ||
var _parser = (0, _parser28.default)('8am-10am'), | ||
start = _parser.start, | ||
end = _parser.end; | ||
var start = _parser.start; | ||
var end = _parser.end; | ||
t.equals(start.getHours(), 8, 'start is 8am'); | ||
@@ -33,7 +32,6 @@ t.equals(end.getHours(), 10, 'end is 10am'); | ||
(0, _tape2.default)('simple am to pm times: 9am-2pm', function (t) { | ||
var _parser2 = (0, _parser28.default)('9am-2pm'); | ||
var _parser2 = (0, _parser28.default)('9am-2pm'), | ||
start = _parser2.start, | ||
end = _parser2.end; | ||
var start = _parser2.start; | ||
var end = _parser2.end; | ||
t.equals(start.getHours(), 9, 'start is 9am'); | ||
@@ -46,7 +44,6 @@ t.equals(end.getHours(), 14, 'end is 2pm (14)'); | ||
(0, _tape2.default)('simple pm times: 1pm-4pm', function (t) { | ||
var _parser3 = (0, _parser28.default)('1pm-4pm'); | ||
var _parser3 = (0, _parser28.default)('1pm-4pm'), | ||
start = _parser3.start, | ||
end = _parser3.end; | ||
var start = _parser3.start; | ||
var end = _parser3.end; | ||
t.equals(start.getHours(), 13, 'start is 1pm (13)'); | ||
@@ -59,7 +56,6 @@ t.equals(end.getHours(), 16, 'end is 4pm (16)'); | ||
(0, _tape2.default)('infer meridiem: 1-3pm', function (t) { | ||
var _parser4 = (0, _parser28.default)('1-3pm'); | ||
var _parser4 = (0, _parser28.default)('1-3pm'), | ||
start = _parser4.start, | ||
end = _parser4.end; | ||
var start = _parser4.start; | ||
var end = _parser4.end; | ||
t.equals(start.getHours(), 13, 'infer start is 1pm (13)'); | ||
@@ -74,7 +70,6 @@ t.equals(end.getHours(), 15, 'end is 3pm (15)'); | ||
var _parser5 = (0, _parser28.default)('1pm-3'); | ||
var _parser5 = (0, _parser28.default)('1pm-3'), | ||
start = _parser5.start, | ||
end = _parser5.end; | ||
var start = _parser5.start; | ||
var end = _parser5.end; | ||
t.equals(start.getHours(), 13, 'start is 1pm (13)'); | ||
@@ -91,8 +86,6 @@ t.equals(end.getHours(), 15, 'infer end is 3pm (15)'); | ||
var _parser6 = (0, _parser28.default)('11pm-2'); | ||
var _parser6 = (0, _parser28.default)('11pm-2'), | ||
start = _parser6.start, | ||
end = _parser6.end; | ||
var start = _parser6.start; | ||
var end = _parser6.end; | ||
t.equals(start.getHours(), 23, 'start is 11pm (23)'); | ||
@@ -107,7 +100,6 @@ t.equals(end.getHours(), 2, 'end is 2am'); | ||
(0, _tape2.default)('minutes: 9:15am-2:30pm', function (t) { | ||
var _parser7 = (0, _parser28.default)('9:15am-2:30pm'); | ||
var _parser7 = (0, _parser28.default)('9:15am-2:30pm'), | ||
start = _parser7.start, | ||
end = _parser7.end; | ||
var start = _parser7.start; | ||
var end = _parser7.end; | ||
t.equals(start.getHours(), 9, 'start is 9am'); | ||
@@ -122,7 +114,6 @@ t.equals(start.getMinutes(), 15, 'start is 9:15am'); | ||
(0, _tape2.default)('colon segmented 24 times: 08:00-13:00', function (t) { | ||
var _parser8 = (0, _parser28.default)('0800-1330'); | ||
var _parser8 = (0, _parser28.default)('0800-1330'), | ||
start = _parser8.start, | ||
end = _parser8.end; | ||
var start = _parser8.start; | ||
var end = _parser8.end; | ||
t.equals(start.getHours(), 8, 'start is 8am'); | ||
@@ -136,7 +127,6 @@ t.equals(end.getHours(), 13, 'end is 1pm (13)'); | ||
(0, _tape2.default)('proper 24h times: 0800-1330', function (t) { | ||
var _parser9 = (0, _parser28.default)('0800-1330'); | ||
var _parser9 = (0, _parser28.default)('0800-1330'), | ||
start = _parser9.start, | ||
end = _parser9.end; | ||
var start = _parser9.start; | ||
var end = _parser9.end; | ||
t.equals(start.getHours(), 8, 'start is 8am'); | ||
@@ -151,7 +141,6 @@ t.equals(end.getHours(), 13, 'end is 1pm (13)'); | ||
(0, _tape2.default)('no leading zero 24h times: 800-1300', function (t) { | ||
var _parser10 = (0, _parser28.default)('800-1300'); | ||
var _parser10 = (0, _parser28.default)('800-1300'), | ||
start = _parser10.start, | ||
end = _parser10.end; | ||
var start = _parser10.start; | ||
var end = _parser10.end; | ||
t.equals(start.getHours(), 8, 'start is 8am'); | ||
@@ -167,8 +156,6 @@ t.equals(end.getHours(), 13, 'end is 1pm (13)'); | ||
(0, _tape2.default)('anchored: dates relative to anchor', function (t) { | ||
var _parser11 = (0, _parser28.default)('8am-1pm', anchor); | ||
var _parser11 = (0, _parser28.default)('8am-1pm', anchor), | ||
start = _parser11.start, | ||
end = _parser11.end; | ||
var start = _parser11.start; | ||
var end = _parser11.end; | ||
t.ok((0, _moment2.default)(start).isSame(anchor, 'day'), 'start is same day as anchor'); | ||
@@ -181,8 +168,6 @@ t.ok((0, _moment2.default)(end).isSame(anchor, 'day'), 'end is same day as anchor'); | ||
(0, _tape2.default)('anchored: dates relative to anchor2', function (t) { | ||
var _parser12 = (0, _parser28.default)('8am-1pm', anchor2); | ||
var _parser12 = (0, _parser28.default)('8am-1pm', anchor2), | ||
start = _parser12.start, | ||
end = _parser12.end; | ||
var start = _parser12.start; | ||
var end = _parser12.end; | ||
t.ok((0, _moment2.default)(start).isSame(anchor2, 'day'), 'start is same day as anchor2'); | ||
@@ -195,8 +180,6 @@ t.ok((0, _moment2.default)(end).isSame(anchor2, 'day'), 'end is same day as anchor2'); | ||
(0, _tape2.default)('overlapping times: 11pm-2am', function (t) { | ||
var _parser13 = (0, _parser28.default)('11pm-2am', anchor); | ||
var _parser13 = (0, _parser28.default)('11pm-2am', anchor), | ||
start = _parser13.start, | ||
end = _parser13.end; | ||
var start = _parser13.start; | ||
var end = _parser13.end; | ||
t.ok((0, _moment2.default)(start).isSame(anchor, 'day'), 'start is same day as anchor'); | ||
@@ -212,8 +195,6 @@ t.ok((0, _moment2.default)(end).isSame((0, _moment2.default)(anchor).add(1, 'day'), 'day'), 'end is day after anchor'); | ||
var _parser14 = (0, _parser28.default)('11pm-2am'); | ||
var _parser14 = (0, _parser28.default)('11pm-2am'), | ||
start = _parser14.start, | ||
end = _parser14.end; | ||
var start = _parser14.start; | ||
var end = _parser14.end; | ||
t.ok((0, _moment2.default)(start).isSame((0, _moment2.default)(today).subtract(1, 'day'), 'day'), 'start is day before today'); | ||
@@ -228,8 +209,6 @@ t.ok((0, _moment2.default)(end).isSame(today, 'day'), 'end is same as today'); | ||
var _parser15 = (0, _parser28.default)('11pm-2am', refDate); | ||
var _parser15 = (0, _parser28.default)('11pm-2am', refDate), | ||
start = _parser15.start, | ||
end = _parser15.end; | ||
var start = _parser15.start; | ||
var end = _parser15.end; | ||
t.ok((0, _moment2.default)(start).isSame(refDate, 'day')); | ||
@@ -242,10 +221,8 @@ t.ok((0, _moment2.default)(end).isSame((0, _moment2.default)(refDate).add(1, 'day'), 'day')); | ||
(0, _tape2.default)('matching text is returned', function (t) { | ||
var _parser16 = (0, _parser28.default)('1-3pm'); | ||
var _parser16 = (0, _parser28.default)('1-3pm'), | ||
text = _parser16.text; | ||
var text = _parser16.text; | ||
var _parser17 = (0, _parser28.default)('1-3pm did some things'), | ||
only = _parser17.text; | ||
var _parser17 = (0, _parser28.default)('1-3pm did some things'); | ||
var only = _parser17.text; | ||
t.equals(text, '1-3pm', 'parser returns matching text'); | ||
@@ -262,8 +239,6 @@ t.equals(only, '1-3pm', 'parser returns only matching text'); | ||
var _parser18 = (0, _parser28.default)('10-4pm'); | ||
var _parser18 = (0, _parser28.default)('10-4pm'), | ||
start = _parser18.start, | ||
end = _parser18.end; | ||
var start = _parser18.start; | ||
var end = _parser18.end; | ||
t.equals(start.getHours(), 10, 'start is 10am'); | ||
@@ -281,8 +256,6 @@ t.equals(end.getHours(), 16, 'end is 4pm (16)'); | ||
var _parser19 = (0, _parser28.default)('9:30-12pm'); | ||
var _parser19 = (0, _parser28.default)('9:30-12pm'), | ||
start = _parser19.start, | ||
end = _parser19.end; | ||
var start = _parser19.start; | ||
var end = _parser19.end; | ||
t.equals(start.getHours(), 9, 'start is 9am'); | ||
@@ -300,8 +273,6 @@ t.equals(start.getMinutes(), 30, 'start is 30 minutes'); | ||
var _parser20 = (0, _parser28.default)('8-4pm Good Friday #stat', today); | ||
var _parser20 = (0, _parser28.default)('8-4pm Good Friday #stat', today), | ||
start = _parser20.start, | ||
end = _parser20.end; | ||
var start = _parser20.start; | ||
var end = _parser20.end; | ||
t.ok((0, _moment2.default)(start).isSame(today, 'day'), 'start is today'); | ||
@@ -314,7 +285,5 @@ t.ok((0, _moment2.default)(end).isSame(today, 'day'), 'end is today'); | ||
(0, _tape2.default)('returns original message without time', function (t) { | ||
var _parser21 = (0, _parser28.default)('1-2pm did some #stuff'); | ||
var _parser21 = (0, _parser28.default)('1-2pm did some #stuff'), | ||
message = _parser21.message; | ||
var message = _parser21.message; | ||
t.equal(message, 'did some #stuff', 'stripped out time'); | ||
@@ -326,9 +295,7 @@ | ||
(0, _tape2.default)('no time needed', function (t) { | ||
var _parser22 = (0, _parser28.default)('did some #stuff'); | ||
var _parser22 = (0, _parser28.default)('did some #stuff'), | ||
text = _parser22.text, | ||
message = _parser22.message, | ||
isRange = _parser22.isRange; | ||
var text = _parser22.text; | ||
var message = _parser22.message; | ||
var isRange = _parser22.isRange; | ||
t.equal(text, '', 'there was no time'); | ||
@@ -342,8 +309,6 @@ t.equal(message, 'did some #stuff', 'stripped out no time'); | ||
(0, _tape2.default)('one time unit is set to start', function (t) { | ||
var _parser23 = (0, _parser28.default)('12pm did some #stuff'); | ||
var _parser23 = (0, _parser28.default)('12pm did some #stuff'), | ||
start = _parser23.start, | ||
end = _parser23.end; | ||
var start = _parser23.start; | ||
var end = _parser23.end; | ||
t.equal(start.getHours(), 12, 'start is 12pm'); | ||
@@ -356,8 +321,6 @@ t.notOk(end, 'end is undefined'); | ||
(0, _tape2.default)('use timezone offset', function (t) { | ||
var _parser24 = (0, _parser28.default)('8am-10am', undefined, -480); | ||
var _parser24 = (0, _parser28.default)('8am-10am', undefined, -480), | ||
start = _parser24.start, | ||
end = _parser24.end; | ||
var start = _parser24.start; | ||
var end = _parser24.end; | ||
t.equals((0, _moment2.default)(start).utc().hour(), 16, 'start is 8am in UTC-08:00'); | ||
@@ -371,7 +334,5 @@ t.equals((0, _moment2.default)(end).utc().hour(), 18, 'end is 10am in UTC-10:00'); | ||
// Test TRUE | ||
var _parser25 = (0, _parser28.default)('8am-10am'), | ||
isTrue = _parser25.isRange; | ||
var _parser25 = (0, _parser28.default)('8am-10am'); | ||
var isTrue = _parser25.isRange; | ||
t.equal(typeof isTrue === 'undefined' ? 'undefined' : _typeof(isTrue), 'boolean', 'is a boolean when true'); | ||
@@ -381,6 +342,5 @@ | ||
var _parser26 = (0, _parser28.default)('8am'); | ||
var _parser26 = (0, _parser28.default)('8am'), | ||
isFalse = _parser26.isRange; | ||
var isFalse = _parser26.isRange; | ||
t.equal(typeof isFalse === 'undefined' ? 'undefined' : _typeof(isFalse), 'boolean', 'is a boolean when false'); | ||
@@ -387,0 +347,0 @@ |
@@ -19,8 +19,6 @@ 'use strict'; | ||
var _e$getDates = e.getDates(); | ||
var _e$getDates = e.getDates(), | ||
start = _e$getDates.start, | ||
end = _e$getDates.end; | ||
var start = _e$getDates.start; | ||
var end = _e$getDates.end; | ||
var yesterday = (0, _moment2.default)().subtract(1, 'day'); | ||
@@ -42,7 +40,5 @@ | ||
var _durationParser = (0, _.durationParser)('5 hours', timezoneOffset); | ||
var _durationParser = (0, _.durationParser)('5 hours', timezoneOffset), | ||
date = _durationParser.date; | ||
var date = _durationParser.date; | ||
var yesterday = (0, _moment2.default)().subtract(1, 'day'); | ||
@@ -49,0 +45,0 @@ |
{ | ||
"name": "tickbin-parser", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "parse strings into entries", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -1,2 +0,2 @@ | ||
[![Build Status](https://semaphoreci.com/api/v1/jonotron/entry-parser/branches/master/shields_badge.svg)](https://semaphoreci.com/jonotron/entry-parser) | ||
[![Build Status](https://semaphoreci.com/api/v1/twostoryrobot/entry-parser/branches/master/shields_badge.svg)](https://semaphoreci.com/twostoryrobot/entry-parser) | ||
@@ -3,0 +3,0 @@ A parser to take strings that look like "May 4 2-4pm I did some #stuff" and parse out all the useful information like start/end time, date, tags, etc. into an object. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98986
1309