UNPKG

@opra/common

Version:
64 lines (63 loc) 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DateTimeTypeTz = void 0; const tslib_1 = require("tslib"); const valgen_1 = require("valgen"); const constants_js_1 = require("../../constants.js"); const simple_type_js_1 = require("../simple-type.js"); const _isDateString = valgen_1.vg.isDateString({ precisionMin: 'tz', coerce: true, }); let DateTimeTypeTz = class DateTimeTypeTz { constructor(attributes) { if (attributes) Object.assign(this, attributes); } [constants_js_1.DECODER](properties) { const fn = _isDateString; const x = [fn]; if (properties.minValue != null) { x.push(valgen_1.vg.isGte(fn(properties.minValue))); } if (properties.maxValue != null) { x.push(valgen_1.vg.isLte(fn(properties.maxValue))); } return x.length > 0 ? valgen_1.vg.pipe(x, { returnIndex: 0 }) : fn; } [constants_js_1.ENCODER](properties) { const fn = _isDateString; const x = [fn]; if (properties.minValue != null) { x.push(valgen_1.vg.isGte(fn(properties.minValue))); } if (properties.maxValue != null) { x.push(valgen_1.vg.isLte(fn(properties.maxValue))); } return x.length > 0 ? valgen_1.vg.pipe(x, { returnIndex: 0 }) : fn; } }; exports.DateTimeTypeTz = DateTimeTypeTz; tslib_1.__decorate([ simple_type_js_1.SimpleType.Attribute({ description: 'Minimum value', }), tslib_1.__metadata("design:type", String) ], DateTimeTypeTz.prototype, "minValue", void 0); tslib_1.__decorate([ simple_type_js_1.SimpleType.Attribute({ description: 'Maximum value', }), tslib_1.__metadata("design:type", String) ], DateTimeTypeTz.prototype, "maxValue", void 0); exports.DateTimeTypeTz = DateTimeTypeTz = tslib_1.__decorate([ ((0, simple_type_js_1.SimpleType)({ name: 'datetimetz', description: 'A full datetime value with time zone information', nameMappings: { js: 'string', json: 'string', }, }).Example('2021-04-18T22:30:15+03:00')), tslib_1.__metadata("design:paramtypes", [Object]) ], DateTimeTypeTz);