127 lines
13 KiB
JavaScript
127 lines
13 KiB
JavaScript
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Timestring = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
Object.defineProperty(exports, '__esModule', {
|
|
value: true
|
|
});
|
|
|
|
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
|
|
|
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; }; })();
|
|
|
|
var Timestring = (function () {
|
|
function Timestring() {
|
|
var settings = arguments[0] === undefined ? {} : arguments[0];
|
|
|
|
_classCallCheck(this, Timestring);
|
|
|
|
var DEFAULT_SETTINGS = {
|
|
hoursPerDay: 24,
|
|
daysPerWeek: 7,
|
|
weeksPerMonth: 4,
|
|
monthsPerYear: 12
|
|
};
|
|
|
|
// merge default settings with user settings
|
|
this.settings = DEFAULT_SETTINGS;
|
|
for (var s in settings) {
|
|
this.settings[s] = settings[s];
|
|
}
|
|
|
|
// time units
|
|
this.units = {
|
|
s: ['s', 'sec', 'secs', 'second', 'seconds'],
|
|
m: ['m', 'min', 'mins', 'minute', 'minutes'],
|
|
h: ['h', 'hr', 'hrs', 'hour', 'hours'],
|
|
d: ['d', 'day', 'days'],
|
|
w: ['w', 'week', 'weeks'],
|
|
mth: ['mth', 'mths', 'month', 'months'],
|
|
y: ['y', 'yr', 'yrs', 'year', 'years']
|
|
};
|
|
|
|
// time unit seconds mappings
|
|
this.unitValues = {
|
|
s: 1,
|
|
m: 60,
|
|
h: 3600
|
|
};
|
|
|
|
// dynamic time unit seconds mappings
|
|
// these are dynamic based on the settings
|
|
this.unitValues.d = this.settings.hoursPerDay * this.unitValues.h;
|
|
this.unitValues.w = this.settings.daysPerWeek * this.unitValues.d;
|
|
this.unitValues.mth = this.settings.weeksPerMonth * this.unitValues.w;
|
|
this.unitValues.y = this.settings.monthsPerYear * this.unitValues.mth;
|
|
}
|
|
|
|
_createClass(Timestring, [{
|
|
key: 'parse',
|
|
value: function parse(string) {
|
|
var _this = this;
|
|
|
|
var returnUnit = arguments[1] === undefined ? 's' : arguments[1];
|
|
|
|
// get unit key helper
|
|
var getUnitKey = function getUnitKey(unit) {
|
|
for (var k in _this.units) {
|
|
for (var u in _this.units[k]) {
|
|
if (unit === _this.units[k][u]) {
|
|
return k;
|
|
}
|
|
}
|
|
}
|
|
|
|
// throw error if invalid unit was passed
|
|
throw new Error('The unit [' + unit + '] is not supported by timestring');
|
|
};
|
|
|
|
// convert a value to a specific unit
|
|
var convert = function convert(value, unit) {
|
|
var baseValue = _this.unitValues[getUnitKey(unit)];
|
|
|
|
return value / baseValue;
|
|
};
|
|
|
|
// get a value in seconds based on a specific unit
|
|
var getSeconds = function getSeconds(value, unit) {
|
|
var baseValue = _this.unitValues[getUnitKey(unit)];
|
|
|
|
return value * baseValue;
|
|
};
|
|
|
|
// seconds counter
|
|
var totalSeconds = 0;
|
|
|
|
// split string into groups and get total seconds for each group
|
|
var groups = string.toLowerCase() // convert words to lower case
|
|
.replace(/[^\.\w+-]+/g, '') // remove white space
|
|
.match(/[-+]?[0-9]+[a-z]+/g); // match time groups (digit followed by time unit - i.e 5d 15m = 2 time groups)
|
|
|
|
if (groups !== null) {
|
|
for (var group in groups) {
|
|
var g = groups[group];
|
|
var value = g.match(/[0-9]+/g)[0];
|
|
var unit = g.match(/[a-z]+/g)[0];
|
|
|
|
totalSeconds += getSeconds(value, unit);
|
|
}
|
|
}
|
|
|
|
return convert(totalSeconds, returnUnit);
|
|
}
|
|
}]);
|
|
|
|
return Timestring;
|
|
})();
|
|
|
|
exports['default'] = Timestring;
|
|
|
|
String.prototype.parseTime = function (unit, settings) {
|
|
return new Timestring(settings).parse(this, unit);
|
|
};
|
|
module.exports = exports['default'];
|
|
|
|
},{}]},{},[1])(1)
|
|
});
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJ0aW1lc3RyaW5nLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7Ozs7OztJQ0FxQixVQUFVO0FBQ2xCLFdBRFEsVUFBVSxHQUNGO1FBQWYsUUFBUSxnQ0FBRyxFQUFFOzswQkFETixVQUFVOztBQUUzQixRQUFNLGdCQUFnQixHQUFHO0FBQ3ZCLGlCQUFXLEVBQUUsRUFBRTtBQUNmLGlCQUFXLEVBQUUsQ0FBQztBQUNkLG1CQUFhLEVBQUUsQ0FBQztBQUNoQixtQkFBYSxFQUFFLEVBQUU7S0FDbEIsQ0FBQzs7O0FBR0YsUUFBSSxDQUFDLFFBQVEsR0FBRyxnQkFBZ0IsQ0FBQztBQUNqQyxTQUFLLElBQUksQ0FBQyxJQUFJLFFBQVEsRUFBRTtBQUFFLFVBQUksQ0FBQyxRQUFRLENBQ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