UNPKG

react-period-of-stay-input

Version:

React.js component for entering a period of stay in a hotel: check-in + check-out date

1 lines 2.02 kB
{"id":"Day.ts","dependencies":[{"name":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/tsconfig.json","includedInParent":true,"mtime":1533819530549},{"name":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/package.json","includedInParent":true,"mtime":1534141269544},{"name":"moment","loc":{"line":10,"column":34},"parent":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/src/Day.ts","resolved":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/node_modules/moment/moment.js"}],"generated":{"js":"\"use strict\";\n\nvar __importStar = this && this.__importStar || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) {\n if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n }result[\"default\"] = mod;\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar moment = __importStar(require(\"moment\"));\nexports.FORMAT = 'YYYY-MM-DD';\nfunction isValidDate(stringValue) {\n return (/^\\d{4}-\\d{2}-\\d{2}$/.test(stringValue) && moment.utc(stringValue, exports.FORMAT).isValid()\n );\n}\nvar Day = /** @class */function () {\n function Day(value) {\n if (typeof value === 'string') {\n if (!isValidDate(value)) {\n throw new Error(value + \" isn't a valid ISO 8601 date literal\");\n }\n this.stringValue = value;\n } else {\n this.stringValue = value.format(exports.FORMAT);\n }\n }\n Day.prototype.toString = function () {\n return this.stringValue;\n };\n Day.prototype.toMoment = function () {\n return moment.utc(this.stringValue);\n };\n Day.prototype.next = function () {\n return new Day(this.toMoment().add(1, 'days'));\n };\n Day.prototype.previous = function () {\n return new Day(this.toMoment().subtract(1, 'days'));\n };\n return Day;\n}();\nexports.default = Day;"},"hash":"8af011ef1812f0e568d5a9ec966469ec","cacheData":{"env":{}}}