ifc-expressions
Version:
Parsing and evaluation of IFC expressions
63 lines (62 loc) • 2.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.IfcTimeStampValue = void 0;
const decimal_js_1 = require("decimal.js");
const Types_js_1 = require("../type/Types.js");
const IfcExpression_js_1 = require("../IfcExpression.js");
const DateFormatException_js_1 = require("../error/value/DateFormatException.js");
const IfcDateTimeValue_js_1 = require("./IfcDateTimeValue.js");
class IfcTimeStampValue {
constructor(value) {
if (typeof value === "string") {
this.timeStamp = new decimal_js_1.Decimal(value);
}
else if (typeof value === "number") {
this.timeStamp = new decimal_js_1.Decimal(value);
}
else {
if (value.isInteger()) {
this.timeStamp = value;
}
else {
throw new DateFormatException_js_1.DateFormatException("Not a valid IfcTimeStamp: " + value.toString());
}
}
if ((0, IfcExpression_js_1.isNullish)(this.timeStamp) ||
this.timeStamp.isNaN() ||
!this.timeStamp.isFinite()) {
throw new DateFormatException_js_1.DateFormatException("Not a valid IfcTimeStamp: " + value);
}
}
static of(value) {
return new IfcTimeStampValue(value);
}
getValue() {
return this;
}
getType() {
return Types_js_1.Type.IFC_TIME_STAMP;
}
static isIfcTimeStampValueType(arg) {
return (arg instanceof IfcTimeStampValue ||
(!(0, IfcExpression_js_1.isNullish)(arg.timeStamp) && arg.timeStamp instanceof decimal_js_1.Decimal));
}
equals(other) {
return (IfcTimeStampValue.isIfcTimeStampValueType(other) &&
this.timeStamp.eq(other.timeStamp));
}
toString() {
return this.timeStamp.toString();
}
compareTo(other) {
return this.timeStamp.comparedTo(other.timeStamp);
}
getTimeStampSeconds() {
return this.timeStamp;
}
toIfcDateTimeValue() {
return IfcDateTimeValue_js_1.IfcDateTimeValue.ofTimeStampSeconds(this.timeStamp);
}
}
exports.IfcTimeStampValue = IfcTimeStampValue;
//# sourceMappingURL=IfcTimeStampValue.js.map