isBefore.js 735 B

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