isBefore.js 762 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isBefore;
  6. var _assertString = require('./util/assertString');
  7. var _assertString2 = _interopRequireDefault(_assertString);
  8. var _toDate = require('./toDate');
  9. var _toDate2 = _interopRequireDefault(_toDate);
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. function isBefore(str) {
  12. var date = arguments.length <= 1 || arguments[1] === undefined ? String(new Date()) : arguments[1];
  13. (0, _assertString2.default)(str);
  14. var comparison = (0, _toDate2.default)(date);
  15. var original = (0, _toDate2.default)(str);
  16. return !!(original && comparison && original < comparison);
  17. }
  18. module.exports = exports['default'];